JSTL FMT不起作用

gjm*_*an2 1 html java 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>
Run Code Online (Sandbox Code Playgroud)

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>
Run Code Online (Sandbox Code Playgroud)

ApplicationResource.properties

message.username=Username
Run Code Online (Sandbox Code Playgroud)

标签目录

\projectName\web\WEB-INF\tags
Run Code Online (Sandbox Code Playgroud)

标签 结果

 Hello // from core
    ???message.username??? //the fmt:message.username not working
Run Code Online (Sandbox Code Playgroud)

谁能帮助我,为什么fmt无效?我尝试使用jstl创建3个或更多项目。所有的jstl都在工作,但只有fmt不能。

gjm*_*an2 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>   
Run Code Online (Sandbox Code Playgroud)