4

我第一次将 Spring Security 与 Spring MVC 和 Tiles 一起使用。使用数据库中的用户/角色进行身份验证一切正常,但是当我添加<security:authorize>标签以根据视图中经过身份验证的用户进行调整时,我收到此错误:

java.lang.ClassNotFoundException: org.springframework.security.access.expression.SecurityExpressionHandler
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
    java.lang.Class.getDeclaredMethods0(Native Method)
    java.lang.Class.privateGetDeclaredMethods(Unknown Source)
    java.lang.Class.getDeclaredMethods(Unknown Source)
    org.apache.catalina.util.Introspection.getDeclaredMethods(Introspection.java:127)
    org.apache.jasper.runtime.TagHandlerPool.get(TagHandlerPool.java:121)
    org.apache.jsp.WEB_002dINF.pages.jsp.indexAdmin2_jsp._jspx_meth_security_005fauthorize_005f0(indexAdmin2_jsp.java:262)
    org.apache.jsp.WEB_002dINF.pages.jsp.indexAdmin2_jsp._jspService(indexAdmin2_jsp.java:223)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
    org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
    org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1047)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:817)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:574)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:343)
    org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
    org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
    org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
    org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:100)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
    org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
    org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
    org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:35)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
    org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:177)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
    org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:188)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
    org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
    org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
    org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:149)
    org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
    org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)

这是导致此问题的 Tile 示例:

<%@taglib prefix="security" uri="http://www.springframework.org/security/tags" %>
<div class="leftpanel">
        <div class="leftmenu">        
            <ul class="nav nav-tabs nav-stacked">
                 <li class="nav-header">iERP</li>
                 <security:authorize ifAnyGranted="ROLE_ADMIN" >
                 <li class="dropdown active"><a href="#"><span class="iconfa-th-list"></span>AAA</a>
                    <ul>
                         <li><a href="GestionServices.erp">Gestion des Services</a></li>
                    </ul>
                </li>
                </security:authorize>
                <security:authorize ifAnyGranted="ROLE_USER" >
                <li class="dropdown active"><a href="#"><span class="iconfa-list-alt"></span>Section de Facturation</a>
                    <ul>
                         <li><a href="FacturesParMois.erp">Facturation Par Périodes</a></li>
                    </ul>
                </li>
                </security:authorize>
            </ul>
       </div>
</div>
4

1 回答 1

2

当我检查我的 WEB-INF/lib 文件夹时,我发现我有不同版本的 spring-security jar,有些是 3.1.4,有些是 3.0.2。它现在与 3.1.4 版本的所有 jar 都运行良好!谢谢卢克,你的评论给了我答案!

于 2013-09-04T12:50:18.253 回答