页面映射不起作用

问题描述 投票:1回答:1

我正在研究一个项目,当我登录我的登录页面时。它显示了下一页,但浏览器保留在login.xhtml而不是test.xhtml中。

这里我认为问题出在applicationContext.xml中:

    <bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
    <property name="securityManager" ref="securityManager"/>
    <property name="loginUrl" value="/login.xhtml"/>
    <property name="successUrl" value="/test.xhtml"/>
    <property name="unauthorizedUrl" value="/unauthorized.xhtml"/>

    <property name="filterChainDefinitions">
        <value>
            /login.xhtml = anon
            /test.xhtml = authc
            /unauthorized.xhtml = anon
        </value>
    </property>
xml hibernate xhtml shiro
1个回答
0
投票

您实际上并没有登录到您的应用程序,并且没有注册会话cookie,因为您使用了两个完全不同的过滤器。您的登录路径设置为anon,丢弃您发布的任何内容,但您的受保护资源路径正在使用authc过滤器,该过滤器需要现在授权或授权调用者。

在一个类似的问题中阅读更多关于这个问题,我回答了here

这是正确的方法并修复了您的问题:

<property name="filterChainDefinitions">
    <value>
        /login.xhtml = authc
        /test.xhtml = authc
        /unauthorized.xhtml = anon
    </value>
</property>

请确保添加logout过滤器以便能够注销您的应用程序。另请注意,您的配置缺少通用的/**过滤器路径,以保护服务器的所有资源。

© www.soinside.com 2019 - 2024. All rights reserved.