【问题标题】:Apache Shiro add URL Exception for Spring MVC projectApache Shiro 为 Spring MVC 项目添加 URL 异常
【发布时间】:2017-01-05 18:37:01
【问题描述】:

我正在使用 Maven + Spring MVC + Apache Shiro 开发一个系统。 这是我的白豆

<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager"> 
    <property name="sessionMode" value="native"/> 
</bean>

<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
    <property name="securityManager" ref="securityManager"/>
    <property name="loginUrl" value="/login.jsp"/> 
    <property name="filters">
        <util:map>
            <entry key="authc">
                <bean class="org.apache.shiro.web.filter.authc.PassThruAuthenticationFilter"/>
            </entry>
        </util:map>
    </property>
    <property name="filterChainDefinitions">
        <value>
            /static/** = anon
            /index.jsp = anon
            /login.jsp = anon
            /user/login = anon
            /user/register = anon 
            /client/face = anon
            /user/logout = logout
            /** = authc
        </value>
    </property>
</bean>

<bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor"/>

添加这些 bean 之后。现在所有请求都将被重定向到登录页面。

我想知道如何添加 URL 例外。像“/show”一样不会被要求登录或任何其他授权方式。

【问题讨论】:

    标签: java spring servlets shiro url-mapping


    【解决方案1】:

    您的 JSP 是否包含不在 /static 中的图像或其他资源?

    至于关于“/show”的问题,你只会在另一条“anon”行中。

    【讨论】:

      猜你喜欢
      • 2014-08-31
      • 2016-07-30
      • 2015-09-18
      • 2012-03-08
      • 2017-08-16
      • 2017-11-24
      • 2012-01-12
      • 2019-01-04
      • 2011-07-20
      相关资源
      最近更新 更多