由于在项目中引入了jstl和shiro标签,导致jsp无法解析,报错内容如下:
org.apache.jasper.JasperException: /index.jsp (line: 2, column: 0) The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application The absolute uri: http://shiro.apache.org/tags cannot be resolved in either web.xml or the jar files deployed with this application] with root cause
引入内容:
<%@ page trimDirectiveWhitespaces="true" isELIgnored="false" session="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
网上的解决方案实在很多,不过好多并不适合,或许大家遇到的具体问题不太一样吧
下面介绍下笔者所遇到的情况供大家参考。
1 依赖包
<properties>
<jstl.version>1.1.2</jstl.version>
<servlet.version>3.0.1</servlet.version>
</properties>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${servlet.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>${jstl.version}</version>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>${jstl.version}</version>
</dependency>
</dependencies>
2 tomcat (笔者使用的为apache-tomcat-7.0.69)下加入jstl和standard的jar包(高版本tomcat可能不需要)
3 web.xml引入本地tld文件
<jsp-config>
<taglib>
<taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
<taglib-location>/WEB-INF/c.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jsp/jstl/functions</taglib-uri>
<taglib-location>/WEB-INF/fn.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jsp/jstl/fmt</taglib-uri>
<taglib-location>/WEB-INF/fmt.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://shiro.apache.org/tags</taglib-uri>
<taglib-location>/WEB-INF/shiro.tld</taglib-location>
</taglib>
</jsp-config>
ok,可以正常访问了。
参考:
https://blog.youkuaiyun.com/broccoli2/article/details/71173401
https://stackoverflow.com/questions/19926554/pwc6188-the-absolute-uri-http-java-sun-com-jsp-jstl-core-cannot-be-resolved
https://stackoverflow.com/tags/jstl/info
https://blog.youkuaiyun.com/lzz313/article/details/7554736
http://ljhzzyx.blog.163.com/blog/static/3838031220128196100902/