开发者

Spring-Security 3.1 java.lang.ClassNotFoundException: org.springframework.security.taglibs.authz.AuthorizeTag

开发者 https://www.devze.com 2023-04-11 01:10 出处:网络
I just upgraded from Spring Security 3.0.5 to 3.1.0.RC3 N开发者_如何学编程ow, the following JSP code gives me java.lang.ClassNotFoundException: org.springframework.security.taglibs.authz.AuthorizeTag

I just upgraded from Spring Security 3.0.5 to 3.1.0.RC3

N开发者_如何学编程ow, the following JSP code gives me java.lang.ClassNotFoundException: org.springframework.security.taglibs.authz.AuthorizeTag

<security:authorize access="not hasRole('ROLE_ANONYMOUS')">
Welcome <%= request.getUserPrincipal().getName() %>
</security:authorize>

I look at the Spring Security Reference Documentation 3.1 and it looks like the <security:authorize> tag should work. However when I look at the directory org.springframework.security.taglibs.authz in spring-security-taglibs-3.1.0.RC3.jar I cannot see any AuthorizeTag.class there.

What is wrong here?

Thanks!


I found that Tomcat might cache the old security.tld, even the spring security library are all 3.1 version. Delete the Tomcat work directory and restart it would works fine now.


I guess you have an old security.tld file somewhere. Make sure that you haven't copied it into your WEB-INF and that you don't have any old Spring Security jars in your classpath.


it is renamed to JspAuthorizeTag

(org.springframework.security.taglibs.authz.JspAuthorizeTag)


Try to update the security.tld (3.0.0.RELEASE):

<tag-class>org.springframework.security.taglibs.authz.AuthorizeTag</tag-class>

to

<tag-class>org.springframework.security.taglibs.authz.JspAuthorizeTag</tag-class>

It's work for my configuration project with FreeMarker

<#assign security=JspTaglibs["/WEB-INF/tlds/security.tld"] />

(mvn jetty:run and mvn tomcat:run). ;-)


To solve this issue in Spring MVC,

You need to add jar/dependency in pom.xml file.

<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>${springsecurity.version}</version>
</dependency>

After adding taglib jar file, you have to import package into your JSP file.

<%@ page import="org.springframework.security.taglibs.authz.JspAuthorizeTag "%> 

Please remove taglib Uri from your JSP file <%@ taglib prefix="authz" uri="http://www.springframework.org/security/tags"%>

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号