我使用的是Spring引导。
我有一个带有以下标签库的JSP页面:
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>
当加载我的jsp页面时,我得到以下错误:
The absolute uri: http://www.springframework.org/security/tags cannot be resolved in either web.xml or the jar files deployed with this application
以下是我的POM依赖项:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
有什么建议吗?
我添加了以下依赖项:
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
</dependency>
现在它起作用了。
添加以下依赖项
For : <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%> :
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
For : <%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%> :
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
</dependency>
使用Tomcat插件分级用户
如果您收到此错误,即使您在gradle.build
中声明了依赖项
runtime "org.springframework.security:spring-security-taglibs:${springSecurityVersion}"
您正在使用Tomcat插件:
apply plugin: 'com.bmuschko.tomcat'
然后,您必须运行渐变任务tomcatRunWar
而不是tomcatRun
,以便将库包含在servlet容器中。
添加taglib库以及安全性可以帮助我解决这个问题:
编译"org.springframework.boot:spring-boot启动器安全性:1.5.22.RELEASE"
implementation group: 'org.springframework.security', name: 'spring-security-taglibs', version: '4.2.11.RELEASE'