您的位置:首页 > 其它

关于web.xml中不能识别taglib的问题

2011-05-09 20:39 232 查看
上午在学习struts-i18n的扩展-jstl-i18n的时候遇到一个问题:
The absolute uri: http://java.sun.com/jsp/jstl/fmt cannot be resolved in either web.xml or the jar files deployed with this application
错误导致页面报告500……
经过查阅得到结果:未引用jar包。
问题解决:将jstl用到的两个jar包jstl.jar和standard.jar copy到WEB-INF下即可。
详述如下:在jsp页面使用jstl标签 fmt 需要首先在jsp页面头部分引用,即<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>。
整个页面代码如下:
<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<fmt:setLocale value="${header[accept-language]}"/>
<fmt:setBundle basename="resource.MessageResources"/>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>Insert title here</title>
</head>
<body>
<form action="login.do" method="post">
<fmt:message key="login.form.filed.username"></fmt:message>:<input type="text" name="username"/><br/>
<fmt:message key="login.form.filed.password"></fmt:message>:<input type="text" name="password"/><br/>
<input type="submit" value="<fmt:message key="login.form.button.login"/>"/>
</form>
</body>
</html>
其中
<fmt:setLocale value="${header[accept-language]}"/>
<fmt:setBundle basename="resource.MessageResources"/>
是设置国际化文本的来源。
<fmt:message key="login.form.filed.username"></fmt:message>
<fmt:message key="login.form.filed.password"></fmt:message>
<fmt:message key="login.form.button.login"/>
就是用来显示国际化文本的fmt标签。由于jstl所用的两个jar包,我开始未引用到WEB-INF文件夹下,造成页面显示报错。
参考网址:飞诺网(www.firnow.com):http://dev.firnow.com/course/3_program/java/javajs/2008107/148863.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: