Spring boot taglibs

时间:2015-02-17 10:54:09

标签: spring jsp spring-mvc spring-boot jsp-tags

我正在使用Spring启动。

我有一个带有以下标记libs的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>

有什么建议吗?

3 个答案:

答案 0 :(得分:14)

我添加了以下依赖项:

<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-taglibs</artifactId>
</dependency>

现在可行。

答案 1 :(得分:4)

添加以下依赖项

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>

答案 2 :(得分:1)

使用Tomcat插件的Gradle用户

如果您在showMessageDialog

中声明了依赖项,则会收到此错误
gradle.build

您正在使用Tomcat插件:

runtime "org.springframework.security:spring-security-taglibs:${springSecurityVersion}"

然后你必须运行gradle任务apply plugin: 'com.bmuschko.tomcat' 而不是tomcatRunWar,以便库包含在你的servlet容器中。