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

本文介绍了解决JSTL和Shiro标签在JSP页面中无法解析的问题,通过配置依赖包、在Tomcat中添加必要的JAR包及在web.xml中正确配置本地TLD文件来确保标签库能被正确识别。

   由于在项目中引入了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/

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值