用浏览器访问Maven Project中一个页面(该页面用到jstl),服务器响应500错误,消息是:
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
用浏览器访问Maven Project中一个页面(该页面用到spring-tag),Tomcat响应500错误,消息是:
The absolute uri: http://www.springframework.org/tags/form cannot be resolved in either web.xml or the jar files deployed with this application
不要在Eclipse中启用Serve modules without publishing模式来部署项目到Tomcat。
如果喜欢折腾,可以尝试方法2
设Maven Project的pom.xml有
<dependency>
<groupId>org.apache.taglibsgroupId>
<artifactId>taglibs-standard-specartifactId>
<version>1.2.5version>
dependency>
<dependency>
<groupId>org.apache.taglibsgroupId>
<artifactId>taglibs-standard-implartifactId>
<version>1.2.5version>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-webmvcartifactId>
<version>4.3.6.RELEASEversion>
dependency>
spring-webmvc-4.3.6.RELEASE.jar
和taglibs-standard-impl-1.2.5.jar
这些jar文件中的META-INF目录包含报错uri对应tld文件,在当前用户目录(如C:\Users\Administrator
)的.m2\repository
中搜索找到它们,并将其复制到src/main/webapp/WEB-INF/lib
<properties>
<webapp.libdir>${project.basedir}/src/main/webapp/WEB-INF/libwebapp.libdir>
properties>
其中project.basedir
为maven内置属性,无须我们再定义
让相关的dependency使用WEB-INF/lib中的文件,指定scope
为system并指定systemPath为WEB-INF/lib中相应jar文件的路径
<dependencies>
<dependency>
<groupId>org.apache.taglibsgroupId>
<artifactId>taglibs-standard-implartifactId>
<version>1.2.5version>
<scope>systemscope>
<systemPath>${webapp.libdir}/taglibs-standard-impl-1.2.5.jarsystemPath>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-webmvcartifactId>
<version>4.3.6.RELEASEversion>
<scope>systemscope>
<systemPath>${webapp.libdir}/spring-webmvc-4.3.6.RELEASE.jarsystemPath>
dependency>
dependencies>