Spring和shiro整合 logout 配置方式

1. 普通的action中 实现本身的logout方法,取到Subject,而后logout这种须要在ShiroFilterFactoryBean 中配置filterChainDefinitions 对应的action的url为anon。
<property name="filterChainDefinitions"> 
    <value> 
      # some example chain definitions: 
      /index.htm = anon 
      /logout = anon 
      /unauthed = anon 
      /console/** = anon 
      /css/** = anon 
      /js/** = anon 
      /lib/** = anon 
      /admin/** = authc, roles[admin] 
      /docs/** = authc, perms[document:read] 
      /** = authc 
      # more URL-to-FilterChain definitions here 
    </value>
</property>

2. 使用shiro提供的logout filter,自定义redirectUrl。 css

<bean id="logout" class="org.apache.shiro.web.filter.authc.LogoutFilter"> 
        <property name="redirectUrl" value="/loginform" /> 
    </bean>

  而后将相应的url filter配置为logout以下 web

<property name="filterChainDefinitions"> 
    <value> 
      # some example chain definitions: 
      /index.htm = anon 
      /logout = logout 
      /unauthed = anon 
      /console/** = anon 
      /css/** = anon 
      /js/** = anon 
      /lib/** = anon 
      /admin/** = authc, roles[admin] 
      /docs/** = authc, perms[document:read] 
      /** = authc 
      # more URL-to-FilterChain definitions here 
    </value>
</property>
相关文章
相关标签/搜索