【发布时间】:2013-10-11 15:27:09
【问题描述】:
以下是我的代码,一切正常,但 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 没有。
【问题讨论】:
-
改用
<c:out value="${applicationScope.message.username}" /> -
或试试
<c:out value"${initParam:message.username}"/> -
@user2511414,感谢您的回复,但我想使用 fmt 标签
-
你使用的是什么服务器,仍然需要在 web.xml 中声明 taglib?!
-
是的,你不应该这样做。
标签: java html jsp jstl struts1