JSP中使用taglib出错终极解决办法

jsp中

<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<c:forEach var="str" items="${users}">
<tr>
<td>
${str}
</td>
</tr>
</c:forEach>


如上使用了foreach等jstl/core中的语法,报错为:

org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files


最简单的办法是把jstl.jar standard.jar复制到tomcat的web-inf/lib中(在tomcat6 webapps/examples/WEB-INF/lib 中也有这两个jar包。


这样总感觉麻烦,有人说要在web.xml部署描述符中这样写:

xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:fmt="http://java.sun.com/jsp/jstl/fmt"

这种方法不行,这个可能确实告诉servlet容器用了什么库,但是并没有把相应的库下载下来,还是得把jstl.jar和standard.jar拷贝到lib目录下,总之得让classloader找得到才行。


你可能感兴趣的:(JSP中使用taglib出错终极解决办法)