使用Maven配置Jstl出现异常:The absolute uri: http://java.sun.com/jsp/jstl/core cannot...
2017-12-28 21:15
681 查看
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page isELIgnored ="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:out value="${request.reportDataKey}"/><br/>
运行时提示:
ClassNotFoundException: javax.servlet.jsp.jstl.core.Config
网上搜索一番,
说是jstl 需要手动引入,于是在pom.xml中添加依赖如下:
再次运行:错误如下:
java.lang.NoClassDefFoundError: org/apache/taglibs/standard/tag/rt/core/Out
刚才我们只是导入了jstl-api,而没有导入jstl的实现,所以再导入jstl 的实现。去mvnrepository上找jstl 的实现,基本上有两个版本,一个是glassfish 的jstl-impl, 另一个是apache的taglibs-standard-impl,一直犹豫不决该用谁,最后在stackoverflow.com/a/25374024/1443527上发现网友分享了他实现的经验,他用的是glassfish版本,所以我们也引人这个。由于tomcat7是兼容j2ee 3.0规范的,所以我们将jstl
依赖的东西给去除掉,防止和tomcat自身的servlet jar包冲突,改正后的依赖为
哈哈,运行正确。
顺便说一下jstl-impl-1.2.jar 和taglibs-standard-impl-1.2.1.jar 的区别,这两个包的内容很相似,后者应该是前者的一个再打包,因为Apache的taglibs工程从2009年以后一直处于停止状态。
如果你要引人后者,那么依赖应该为:
<%@ page isELIgnored ="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:out value="${request.reportDataKey}"/><br/>
运行时提示:
ClassNotFoundException: javax.servlet.jsp.jstl.core.Config
网上搜索一番,
说是jstl 需要手动引入,于是在pom.xml中添加依赖如下:
<dependency> <groupId>javax.servlet.jsp.jstl</groupId> <artifactId>jstl-api</artifactId> <version>1.2</version> </dependency>
再次运行:错误如下:
java.lang.NoClassDefFoundError: org/apache/taglibs/standard/tag/rt/core/Out
刚才我们只是导入了jstl-api,而没有导入jstl的实现,所以再导入jstl 的实现。去mvnrepository上找jstl 的实现,基本上有两个版本,一个是glassfish 的jstl-impl, 另一个是apache的taglibs-standard-impl,一直犹豫不决该用谁,最后在stackoverflow.com/a/25374024/1443527上发现网友分享了他实现的经验,他用的是glassfish版本,所以我们也引人这个。由于tomcat7是兼容j2ee 3.0规范的,所以我们将jstl
依赖的东西给去除掉,防止和tomcat自身的servlet jar包冲突,改正后的依赖为
<dependency> <groupId>javax.servlet.jsp.jstl</groupId> <artifactId>jstl-api</artifactId> <version>1.2</version> <exclusions> <exclusion> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> </exclusion> <exclusion> <groupId>javax.servlet.jsp</groupId> <artifactId>jsp-api</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.glassfish.web</groupId> <artifactId>jstl-impl</artifactId> <version>1.2</version> <exclusions> <exclusion> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> </exclusion> <exclusion> <groupId>javax.servlet.jsp</groupId> <artifactId>jsp-api</artifactId> </exclusion> <exclusion> <groupId>javax.servlet.jsp.jstl</groupId> <artifactId>jstl-api</artifactId> </exclusion> </exclusions> </dependency>
哈哈,运行正确。
顺便说一下jstl-impl-1.2.jar 和taglibs-standard-impl-1.2.1.jar 的区别,这两个包的内容很相似,后者应该是前者的一个再打包,因为Apache的taglibs工程从2009年以后一直处于停止状态。
如果你要引人后者,那么依赖应该为:
<dependency> <groupId>org.apache.taglibs</groupId> <artifactId>taglibs-standard-spec</artifactId> <version>1.2.1</version> </dependency> <dependency> <groupId>org.apache.taglibs</groupId> <artifactId>taglibs-standard-impl</artifactId> <version>1.2.1</version> </dependency>
相关文章推荐
- 【错误解决】[Maven]使用Maven配置Jstl出现异常:The absolute uri: http://java.sun.com/jsp/jstl/core cannot...
- maven使用jstl表达式和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解决
- 使用jstl标签时提示The absolute uri: http://java.sun.com/jsp/jstl/core cannot
- WEB项目中出现The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in ei问题的解决方法
- 使用Jstl异常:The absolute uri: http://java.sun.com/jsp/jstl/core cannot&nbs
- 使用Jstl异常:HTTP Status 500 - The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in
- 使用Jstl异常:HTTP Status 500 - The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved i
- Maven项目启动报错:The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml
- 【小平工作日志】java 异常absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml
- myeclipse8.6使用jstl遇到的错误The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in eit
- org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be res
- The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar
- The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar
- Jsp 报错 错误 PWC6188: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either
- The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar
- org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be res
- The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved
- The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved问题
- The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files
- org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be res