JSF + SpringSecurity网址未被截获

时间:2012-04-28 15:17:54

标签: java jsf spring-security

运行JSF和Spring Security时遇到问题。

WEB.XML:          

    <!-- spring and jsf configuration files mapping -->
    ...

    <!-- JSF mapping -->
    ...

    <!-- Spring Security -->
    <filter>
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class>
            org.springframework.web.filter.DelegatingFilterProxy
        </filter-class>
    </filter>

    <filter-mapping>
        <filter-name>springSecurityFilterChain</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

</web-app>

securityContext.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
    xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/security
    http://www.springframework.org/schema/security/spring-security-3.0.3.xsd">

    <http auto-config="true">
        <intercept-url pattern="/pages**" access="ROLE_USER" />
    </http>

    <authentication-manager>
        <authentication-provider>
            <user-service>
                <user name="evgeny" password="123" authorities="ROLE_USER" />
            </user-service>
        </authentication-provider>
    </authentication-manager>

</beans:beans>
访问

http://localhost:8081/spring/pages/userInfo.jsf没有问题!

1 个答案:

答案 0 :(得分:0)

根据您提供的示例网址(http://localhost:8081/spring/pages/userInfo.jsf

<intercept-url pattern="/pages**" access="ROLE_USER" />

应更改为以下内容以匹配

<intercept-url pattern="/spring/pages**" access="ROLE_USER" />