Spring Security,JSP Tag Lib Error

时间:2014-02-18 09:24:31

标签: spring jsp maven spring-security

我想在我的JSP文件中包含spring security标记(在JSP taglib scriptlet中表示),所以我在JSP中添加了以下行 taglib prefix =“security”uri =“http://www.springframework.org/security/tags”(在JSP标记库中)

但我收到了以下错误 home.jsp:2:5:使用此URI无法找到标记库。可能的原因可能是URI不正确,或者在解析.tld文件时出错。

<dependency>
    <groupId>org.springframework.security</groupId>
     <artifactId>spring-security-web</artifactId>
     <version>3.0.5.RELEASE</version>
</dependency>

<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-core</artifactId>
    <version>3.0.5.RELEASE</version>
</dependency>

<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-config</artifactId>
    <version>3.0.5.RELEASE</version>
</dependency>

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

3 个答案:

答案 0 :(得分:2)

<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>

对我有用,有了这些

 <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
            <version>${spring.security.version}</version>
            <scope>${defaultScope}</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-core</artifactId>
            <version>${spring.security.version}</version>
            <scope>${defaultScope}</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-web</artifactId>
            <version>${spring.security.version}</version>
            <scope>${defaultScope}</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-taglibs</artifactId>
            <version>${spring.security.version}</version>
            <scope>${defaultScope}</scope>
        </dependency>

其中spring.security.version = 3.1.4.RELEASE。

并确保你已经包含了正确的jst jar。

答案 1 :(得分:2)

Gradle,添加到build.gradle

compile "org.springframework.security:spring-security-taglibs:$springSecurityVersion"

compile "org.springframework.security:spring-security-taglibs:3.2.0.RELEASE"

或您的版本

答案 2 :(得分:1)

我发现其他方式并不是一个好方法,但它是如何为我工作,我已将所有.class复制到/ WEB-INF /类并将.tld文件复制到/ WEB-INF中当我正在部署项目时,我正在使用&lt;%@ taglib prefix =“sec”uri =“http://www.springframework.org/security/tags”%但是在部署项目之后我已经将我的taglib元素更改为@ taglib prefix =“sec”uri =“/ WEB-INF / security.tld”并且使用了弹簧安全标签并且工作正常我知道这不是一个好方法但是我想要学习弹簧这对我有用:)