![](/img/trans.png)
[英]I can pass a variable from a JSP scriptlet to JSTL but not from JSTL to a JSP scriptlet without an error
[英]Why can I not transfer a scriptlet attribute to JSTL in this JSP custom tag?
字符串:
${prettyDate}
通過此自定義標簽而不是經過修飾的Date字符串輸出到頁面:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ tag import="com.ocpsoft.pretty.time.PrettyTime, java.util.Date"%>
<%@ attribute name="dateParam" required="true" type="java.util.Date" %>
<%
PrettyTime p = new PrettyTime();
String prettyDate = p.format(dateParam);
jspContext.setAttribute("prettyDate", prettyDate);
%>
<c:out value="${prettyDate}"/>
為什么這樣做會阻止scriptlet屬性( prettyDate
)轉移到此JSP自定義標記中的JSTL?
您的Web應用程序是哪個版本? 如果仍在使用JSP 1.2,則必須將isELIgnored
頁面指令顯式設置為false
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.