0

我在运行 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>

安全上下文.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访问没有问题!

4

1 回答 1

0

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

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

应更改为以下以匹配它

<intercept-url pattern="/spring/pages**" access="ROLE_USER" />
于 2012-04-29T07:29:36.997 回答