shiro 拦截了所有请求 感觉shiroFilter配置无效

IW_JKTM 2017-10-16 05:25:38
Spring-shiro.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">

<!-- rememberme配置 -->
<bean id="rememberMeCookie" class="org.apache.shiro.web.servlet.SimpleCookie">
<constructor-arg value="rememberMe"></constructor-arg>
<property name="httpOnly" value="true"></property>
<!-- 记住7天 -->
<property name="maxAge" value="604800"></property>
</bean>

<!-- remember管理器 -->
<bean id="rememberMeManager" class="org.apache.shiro.web.mgt.CookieRememberMeManager">
<!-- 加密密钥 -->
<property name="cipherKey" value="#{T(org.apache.shiro.codec.Base64).decode('4AvVhmFLUs0KTA3Kprsdag==')}"></property>
<property name="cookie" ref="rememberMeCookie"></property>
</bean>

<!-- web.xml中shiro的filter对应的bean -->
<!-- 配置securityManager-->
<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
<property name="realm" ref="gyrealm"></property>
<property name="rememberMeManager" ref="rememberMeManager"></property>
</bean>
<!-- 自定义realm-->
<bean id="gyrealm" class="cn.gy.wfs.realm.GYRealm"></bean>
<!-- 记住我功能设置session的Filter -->
<bean id="rememberMeFilter" class="cn.gy.wfs.realm.RememberMeFilter">
<property name="rememberMeParam" value="rememberme"></property>
</bean>
<!-- shiro的web过滤器 -->
<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
<property name="securityManager" ref="securityManager"></property>
<!-- 要求登录时的链接(登录页面地址),非必须的属性,默认会自动寻找Web工程根目录下的"/login.jsp"页面 -->
<!--<property name="loginUrl" value="/admin/show"></property>-->
<!-- 身份认证失败跳转页面 -->
<property name="loginUrl" value="/login.jsp"></property>
<!-- 权限认证失败跳转页面 -->
<property name="unauthorizedUrl" value="/unauthor.jsp"></property>
<property name="filters">
<map>
<!-- rememberMe过滤器 -->
<entry key="rememberMe" value-ref="rememberMeFilter"></entry>
</map>
</property>
<property name="filterChainDefinitions">
<value>
<!-- /index.jsp = anon
/home.do = anon
/login.do = anon
/logout.do = logout
/agent/**=roles[agent]
/** = anon
/css/** = anon
/js/** = anon
/images/** = anon
/fonts/** = anon-->
/** = anon
</value>
</property>
</bean>

</beans>
web.xml:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:spring-*.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!--shiro过滤器 -->
<filter>
<filter-name>shiroFilter</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
<init-param>
<param-name>targetFilterLifecycle</param-name>
<param-value>true</param-value>
</init-param>
<!--设置spring容器filter的bean id,如果不设置则找与filter-name一致的bean -->
<init-param>
<param-name>targetBeanName</param-name>
<param-value>shiroFilter</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>shiroFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- 配置核心控制器 -->
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring-mvc.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
...全文
1530 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
越活越精彩 2018-12-04
  • 打赏
  • 举报
回复
/* 就是会拦截绝大部分请求 .do请求也会被拦截 你把shiro/*换成*.admin 就能访问到了
IW_JKTM 2017-10-20
  • 打赏
  • 举报
回复
我这个重新加载Tomcat配置文件就好了。

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧