JSTL fmt无法正常工作

时间:2013-10-11 15:27:10

标签: java html jsp jstl struts1

以下是我的代码,一切正常,但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

Tags结果

 Hello // from core
    ???message.username??? //the fmt:message.username not working

任何人都可以帮助我,为什么fmt不起作用?我尝试使用jstl创建3个或更多项目。所有的jstl都在工作,但只有fmt没有。

1 个答案:

答案 0 :(得分:5)

最后我解决了。 以下代码必须插入 web.xml

<context-param>
        <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
        <param-value>com.projectName.resources.ApplicationResource</param-value>
</context-param>   
相关问题