Spring 引导标签库
Spring boot taglibs
我正在使用 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>
现在可以了。
Gradle 用户使用 Tomcat 插件
如果您在 gradle.build
中声明了依赖项,但仍收到此错误
runtime "org.springframework.security:spring-security-taglibs:${springSecurityVersion}"
并且您正在使用 Tomcat 插件:
apply plugin: 'com.bmuschko.tomcat'
那么您必须 运行 gradle 任务 tomcatRunWar
而不是 tomcatRun
,这样库就会包含在您的 servlet 容器中。
添加以下依赖
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>
添加 taglib 库和安全性帮助我解决了这个问题:
编译'org.springframework.boot:spring-boot-starter-security:1.5.22.RELEASE'
implementation group: 'org.springframework.security', name: 'spring-security-taglibs', version: '4.2.11.RELEASE'
我正在使用 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>
现在可以了。
Gradle 用户使用 Tomcat 插件
如果您在 gradle.build
runtime "org.springframework.security:spring-security-taglibs:${springSecurityVersion}"
并且您正在使用 Tomcat 插件:
apply plugin: 'com.bmuschko.tomcat'
那么您必须 运行 gradle 任务 tomcatRunWar
而不是 tomcatRun
,这样库就会包含在您的 servlet 容器中。
添加以下依赖
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>
添加 taglib 库和安全性帮助我解决了这个问题:
编译'org.springframework.boot:spring-boot-starter-security:1.5.22.RELEASE'
implementation group: 'org.springframework.security', name: 'spring-security-taglibs', version: '4.2.11.RELEASE'