[英]JSTL fmt not working
下面是我的代碼,一切正常,但fmt不好。
web.xml
<jsp-config>
<taglib>
<taglib-uri>/WEB-INF/tags/jstl-fmt.tld</taglib-uri>
<taglib-location>/WEB-INF/tags/fmt.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/tags/jstl-fmt-1_0.tld</taglib-uri>
<taglib-location>/WEB-INF/tags/fmt-1_0.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/tags/jstl-fmt-1_0-rt.tld</taglib-uri>
<taglib-location>/WEB-INF/tags/fmt-1_0-rt.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/tags/jstl-c.tld</taglib-uri>
<taglib-location>/WEB-INF/tags/c.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/tags/jstl-c-1_0.tld</taglib-uri>
<taglib-location>/WEB-INF/tags/c-1_0.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/tags/jstl-c-1_0-rt.tld</taglib-uri>
<taglib-location>/WEB-INF/tags/c-1_0-rt.tld</taglib-location>
</taglib>
</jsp-config>
Sample.jsp
<%@ taglib uri="/WEB-INF/tags/jstl-fmt.tld" prefix="fmt" %>
<%@ taglib uri="/WEB-INF/tags/jstl-c.tld" prefix="c" %>
<html:form action="/UserAction.do">
<fmt:message key="message.username"/>
<c:out value="Hello" />
</html:form>
ApplicationResource.properties
message.username=Username
標簽目錄
\projectName\web\WEB-INF\tags
結果
Hello // from core
???message.username??? //the fmt:message.username not working
誰能幫助我,為什么fmt無效? 我嘗試使用jstl創建3個或更多項目。 所有的jstl都在工作,但只有fmt不能。
終於我解決了。 必須在web.xml中插入以下代碼
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>com.projectName.resources.ApplicationResource</param-value>
</context-param>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.