记录下来,便于记忆。
1、web.xml文件的配置
<?xml version="1.0" encoding="UTF-8"?>
<!-- Web容器加载顺序ServletContext--context-param--listener--filter--servlet -->
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<display-name>项目</display-name>
<!-- 指定Spring的配置文件 -->
<!-- 否则Spring会默认从WEB-INF下寻找配置文件,contextConfigLocation属性是Spring内部固定的 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext*.xml</param-value>
</context-param>
<!-- 防止发生java.beans.Introspector内存泄露,应将它配置在ContextLoaderListener的前面 -->
<listener>
<listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
</listener>
<!-- 实例化Spring容器 -->
<!-- 应用启动时,该监听器被执行,它会读取Spring相关配置文件,其默认会到WEB-INF中查找applicationContext.xml -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- 解决乱码问题 -->
<!-- forceEncoding默认为false,此时效果可大致理解为request.setCharacterEncoding("UTF-8") -->
<!-- forceEncoding=true后,可大致理解为request.setCharacterEncoding("UTF-8")和response.setCharacterEncoding("UTF-8") -->
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- WebStatFilter用于采集web-jdbc关联监控的数据。 -->
<filter>
<filter-name>DruidWebStatFilter</filter-name>
<filter-class>com.alibaba.druid.support.http.WebStatFilter</filter-class>
<init-param>
<param-name>exclusions</param-name>
<param-value>*.js,*.gif,*.jpg,*.png,*.css,*.ico,*.jsp,/druid/*,/download/*</param-value>
</init-param>
<init-param>
<param-name>sessionStatMaxCount</param-name>
<param-value>2000</param-value>
</init-param>
<init-param>
<param-name>sessionStatEnable</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>principalSessionName</param-name>
<param-value>session_user_key</param-value>
</init-param>
<init-param>
<param-name>profileEnable</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>DruidWebStatFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- 配置Shiro过滤器,先让Shiro过滤系统接收到的请求 -->
<!-- 这里filter-name必须对应applicationContext.xml中定义的<bean id="shiroFilter"/> -->
<!-- 使用[/*]匹配所有请求,保证所有的可控请求都经过Shiro的过滤 -->
<!-- 通常会将此filter-mapping放置到最前面(即其他filter-mapping前面),以保证它是过滤器链中第一个起作用的 -->
<filter>
<filter-name>shiroFilter</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
<!-- <init-param>
该值缺省为false,表示生命周期由SpringApplicationContext管理,设置为true则表示由ServletContainer管理
<param-name>targetFilterLifecycle</param-name>
<param-value>true</param-value>
</init-param> -->
</filter>
<filter-mapping>
<filter-name>shiroFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>DruidStatView</servlet-name>
<servlet-class>com.alibaba.druid.support.http.StatViewServlet</servlet-class>
<init-param>
<param-name>resetEnable</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>loginUsername</param-name>
<param-value>druid</param-value>
</init-param>
<init-param>
<param-name>loginPassword</param-name>
<param-value>druid</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>DruidStatView</servlet-name>
<url-pattern>/druid/*</url-pattern>
</servlet-mapping>
<!-- SpringMVC核心分发器 -->
<servlet>
<servlet-name>mvcServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:webmvc/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>mvcServlet</servlet-name>
<url-pattern>*.action</url-pattern>
<url-pattern>*.json</url-pattern>
<url-pattern>*.page</url-pattern>
</servlet-mapping>
<!-- webservice————Web 服务框架
介绍:https://www.ibm.com/developerworks/cn/java/j-jws12.html -->
<servlet>
<servlet-name>cxf</servlet-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>cxf</servlet-name>
<url-pattern>/ws/*</url-pattern>
</servlet-mapping>
<!-- Session超时30分钟(零或负数表示会话永不超时)-->
<!--
<session-config>
<session-timeout>30</session-timeout>
</session-config>
-->
<!-- 默认欢迎页 -->
<!-- Servlet2.5中可直接在此处执行Servlet应用,如<welcome-file>servlet/InitSystemParamServlet</welcome-file> -->
<!-- 这里使用了SpringMVC提供的<mvc:view-controller>标签,实现了首页隐藏的目的,详见applicationContext.xml -->
<!--
<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>
-->
<!-- 错误展示页面配置-->
<error-page>
<error-code>405</error-code>
<location>/WEB-INF/405.html</location>
</error-page>
<error-page>
<error-code>404</error-code>
<location>/WEB-INF/404.jsp</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/WEB-INF/500.jsp</location>
</error-page>
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/WEB-INF/500.jsp</location>
</error-page>
</web-app>
2、spring-mvc.xml文件的配置 也可能会命名为:(servlet-context.xml \spring-context)
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans
xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
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">
<!--
Spring-WebMVC的DispatcherServlet环境配置: 定义处理请求的框架信息
-->
<!-- 它背后注册了很多用于解析注解的处理器,其中就包括<context:annotation-config/>配置的注解所使用的处理器 -->
<!-- 所以配置了<context:component-scan base-package="">之后,便无需再配置<context:annotation-config> -->
<context:component-scan base-package="com.papio"/>
<!-- 由 Spring进行扫描, 启用 Spring MVC 自动扫描 @Controller 注解的编程模型 -->
<!-- 启用SpringMVC的注解功能,它会自动注册HandlerMapping、HandlerAdapter、ExceptionResolver的相关实例 -->
<annotation-driven />
<!-- 扫描的base包 -->
<context:component-scan base-package="com.sinog2c.mvc.controller,com.sinog2c.query.mvc.controller">
<!-- 将service排除在外,意味着MVC中不初始化service,防止事务失效 -->
<context:exclude-filter type="annotation"
expression="org.springframework.stereotype.Service" />
</context:component-scan>
<interceptors>
<!-- 使用bean定义一个Interceptor,拦截所有的 *.action请求; 此处顺序即为拦截器链的顺序-->
<beans:bean class="com.sinog2c.mvc.interceptor.LoginCheckInterceptor">
<beans:property name="excludeList">
<beans:list>
<beans:value>/login.action</beans:value>
<beans:value>/logout.action</beans:value>
<beans:value>/loginPage.page</beans:value>
<!--....... -->
</beans:list>
</beans:property>
</beans:bean>
</interceptors>
<!-- JSP视图解析器,根据 @Controller 返回的视图名字转换到 /JSP/xxxx1/xxx2.jsp 文件 -->
<!-- 配置SpringMVC的视图解析器 -->
<!-- 其viewClass属性的默认值就是org.springframework.web.servlet.view.JstlView -->
<beans:bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/JSP/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
<!-- 默认访问跳转到登录页面(即定义无需Controller的url<->view直接映射) -->
<mvc:view-controller path="/" view-name="forward:/login.jsp"/>
<!-- 由于web.xml中设置是:由SpringMVC拦截所有请求,于是在读取静态资源文件的时候就会受到影响(说白了就是读不到) -->
<!-- 经过下面的配置,该标签的作用就是:所有页面中引用"/js/**"的资源,都会从"/resources/js/"里面进行查找 -->
<!-- 我们可以访问http://IP:8080/xxx/js/my.css和http://IP:8080/xxx/resources/js/my.css对比出来 -->
<mvc:resources mapping="/js/**" location="/resources/js/"/>
<mvc:resources mapping="/css/**" location="/resources/css/"/>
<mvc:resources mapping="/WEB-INF/**" location="/WEB-INF/"/>
<!-- 文件上传处理器,申明的id必须为multipartResolver -->
<beans:bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<!--
允许上传的最大文件大小,100M字节。当设为-1时表示无限制,默认是-1,
-->
<beans:property name="maxUploadSize" value="-1" />
<!-- 在文件上传时允许写到内存中的最大值,以字节为单位计算,默认是10240 -->
<beans:property name="maxInMemorySize" value="4096" />
<!-- 上传文件时的临时目录,默认是Servlet容器的临时目录 -->
</beans:bean>
<!-- 错误处理器 -->
<beans:bean id="exceptionResolver" class="com.sinog2c.mvc.errorhandler.ExceptionHandler" />
<!-- 异常映射 -->
<!-- SpringMVC在超出上传文件限制时,会抛出org.springframework.web.multipart.MaxUploadSizeExceededException -->
<!-- 该异常是SpringMVC在检查上传的文件信息时抛出来的,而且此时还没有进入到Controller方法中 -->
<beans:bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<beans:property name="exceptionMappings">
<beans:props>
<!-- 当抛出NumberFormatException时返回名叫number的视图 -->
<beans:prop key="NumberFormatException">number</beans:prop>
<beans:prop key="NullPointerException">null</beans:prop>
<!-- 遇到MaxUploadSizeExceededException异常时,自动跳转到/WEB-INF/error_fileupload.jsp页面 -->
<beans:prop key="MaxUploadSizeExceededException">WEB-INF/error_fileupload</beans:prop>
<!-- 处理其它异常(包括Controller抛出的) -->
<prop key="java.lang.Throwable">WEB-INF/500</prop>
</beans:props>
</beans:property>
<!-- 当抛出异常但没有在exceptionMappings里面找到对应的异常时 返回名叫exception的视图 -->
<beans:property name="defaultErrorView" value="exception" />
<!-- 定义在发生异常时视图跟返回码的对应关系 -->
<beans:property name="statusCodes">
<beans:props>
<!-- 发生NumberFormatException时返回视图number,对应HttpServletResponse的返回码500 -->
<beans:prop key="number">500</beans:prop>
<beans:prop key="null">503</beans:prop>
</beans:props>
</beans:property>
<!-- 发生异常时默认的HttpServletResponse的返回码,默认是200 -->
<beans:property name="defaultStatusCode" value="404" />
</beans:bean>
<!-- Jackson转换器 -->
<beans:bean id="mappingJacksonHttpMessageConverter"
class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter" />
<!-- enum枚举值的引用方法 -->
<beans:bean id="DisableCircularReferenceDetect" class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean" >
<beans:property name="staticField" value="com.alibaba.fastjson.serializer.SerializerFeature.DisableCircularReferenceDetect"></beans:property>
</beans:bean>
<beans:bean id="WriteNullStringAsEmpty" class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean" >
<beans:property name="staticField" value="com.alibaba.fastjson.serializer.SerializerFeature.WriteNullStringAsEmpty"></beans:property>
</beans:bean>
<beans:bean id="WriteNullNumberAsZero" class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean" >
<beans:property name="staticField" value="com.alibaba.fastjson.serializer.SerializerFeature.WriteNullNumberAsZero"></beans:property>
</beans:bean>
<beans:bean id="WriteMapNullValue" class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean" >
<beans:property name="staticField" value="com.alibaba.fastjson.serializer.SerializerFeature.WriteMapNullValue"></beans:property>
</beans:bean>
<!-- fastjson转换器 -->
<beans:bean id="fastJsonHttpMessageConverter"
class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter" >
<!-- 避免IE执行AJAX时,返回JSON出现下载文件 -->
<beans:property name="supportedMediaTypes">
<beans:list>
<beans:value>text/html;charset=UTF-8</beans:value>
</beans:list>
</beans:property>
<!-- 转换时的特性设置 -->
<beans:property name="features">
<beans:array>
<!-- 避免默认的循环引用替换 -->
<beans:ref bean="DisableCircularReferenceDetect" />
<beans:ref bean="WriteNullStringAsEmpty" />
<beans:ref bean="WriteNullNumberAsZero" />
<beans:ref bean="WriteMapNullValue" />
</beans:array>
</beans:property>
</beans:bean>
<beans:bean
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<beans:property name="messageConverters">
<beans:list>
<!-- json转换器 -->
<beans:ref bean="fastJsonHttpMessageConverter" />
</beans:list>
</beans:property>
</beans:bean>
</beans:beans>
3、spring-shiro.xml文件配置(这个文件是对shiro权限框架的配置)
<?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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<description>== Shiro Components ==</description>
<!-- 会话Session ID生成器 -->
<bean id="sessionIdGenerator" class="org.apache.shiro.session.mgt.eis.JavaUuidSessionIdGenerator"/>
<!-- 会话Cookie模板 -->
<bean id="sessionIdCookie" class="org.apache.shiro.web.servlet.SimpleCookie">
<!--cookie的name,我故意取名叫xxxxbaidu -->
<constructor-arg value="v_v-s-baidu"/>
<property name="httpOnly" value="true"/>
<!--cookie的有效时间 -->
<property name="maxAge" value="-1"/>
</bean>
<!-- custom shiro session listener -->
<bean id="customSessionListener" class="com.sojson.core.shiro.listenter.CustomSessionListener">
<property name="shiroSessionRepository" ref="jedisShiroSessionRepository"/>
</bean>
<!-- rememberMe管理器 -->
<!-- 用户信息记住我功能的相关配置 -->
<bean id="rememberMeCookie" class="org.apache.shiro.web.servlet.SimpleCookie">
<constructor-arg value="v_v-re-baidu"/>
<property name="httpOnly" value="true"/>
<!-- 配置存储rememberMe Cookie的domain为 一级域名
<property name="domain" value=".itboy.net"/>
-->
<property name="maxAge" value="2592000"/><!-- 30天时间,记住我30天 -->
</bean>
<!-- rememberMe管理器 -->
<bean id="rememberMeManager" class="org.apache.shiro.web.mgt.CookieRememberMeManager">
<!-- rememberMe cookie加密的密钥 建议每个项目都不一样 默认AES算法 密钥长度(128 256 512 位)-->
<property name="cipherKey"
value="#{T(org.apache.shiro.codec.Base64).decode('3AvVhmFLUs0KTA3Kprsdag==')}"/>
<property name="cookie" ref="rememberMeCookie"/>
</bean>
<!-- custom shiro session listener -->
<bean id="customShiroSessionDAO" class="com.sojson.core.shiro.CustomShiroSessionDAO">
<property name="shiroSessionRepository" ref="jedisShiroSessionRepository"/>
<property name="sessionIdGenerator" ref="sessionIdGenerator"/>
</bean>
<!-- 手动操作Session,管理Session -->
<bean id="customSessionManager" class="com.sojson.core.shiro.session.CustomSessionManager">
<property name="shiroSessionRepository" ref="jedisShiroSessionRepository"/>
<property name="customShiroSessionDAO" ref="customShiroSessionDAO"/>
</bean>
<!-- 会话验证调度器 -->
<bean id="sessionValidationScheduler" class="org.apache.shiro.session.mgt.ExecutorServiceSessionValidationScheduler">
<!-- 间隔多少时间检查,不配置是60分钟 -->
<property name="interval" value="${session.validate.timespan}"/>
<property name="sessionManager" ref="sessionManager"/>
</bean>
<!-- Shiro默认会使用Servlet容器的Session,可通过sessionMode属性来指定使用Shiro原生Session 我是用的是redis-->
<!-- 即<property name="sessionMode" value="native"/>,详细说明见官方文档 -->
<!-- 这里主要是设置自定义的单Realm应用,若有多个Realm,可使用'realms'属性代替 -->
<!-- 安全管理器 -->
<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
<property name="realm" ref="sampleRealm"/>
<!-- 会话管理 -->
<property name="sessionManager" ref="sessionManager"/>
<!-- remberme管理器 -->
<property name="rememberMeManager" ref="rememberMeManager"/>
<!-- 使用配置的缓存管理器 -->
<property name="cacheManager" ref="customShiroCacheManager"/>
</bean>
<!-- 用户缓存 -->
<!-- shiro 缓存实现,对ShiroCacheManager,我是采用redis的实现 -->
<bean id="customShiroCacheManager" class="com.sojson.core.shiro.cache.impl.CustomShiroCacheManager">
<property name="shiroCacheManager" ref="jedisShiroCacheManager"/>
</bean>
<!-- shiro 缓存实现,对ShiroCacheManager,我是采用redis的实现 -->
<bean id="jedisShiroCacheManager" class="com.sojson.core.shiro.cache.impl.JedisShiroCacheManager">
<property name="jedisManager" ref="jedisManager"/>
</bean>
<!-- redis 的缓存 -->
<bean id="jedisManager" class="com.sojson.core.shiro.cache.JedisManager">
<property name="jedisPool" ref="jedisPool"/>
</bean>
<!-- 静态注入,相当于调用SecurityUtils.setSecurityManager(securityManager) -->
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="staticMethod" value="org.apache.shiro.SecurityUtils.setSecurityManager"/>
<property name="arguments" ref="securityManager"/>
</bean>
<!-- session 校验单个用户是否多次登录 -->
<bean id="kickoutSessionFilter" class="com.sojson.core.shiro.filter.KickoutSessionFilter">
<property name="kickoutUrl" value="/u/login.shtml?kickout"/>
</bean>
<!-- 静态注入 jedisShiroSessionRepository-->
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="staticMethod" value="com.sojson.core.shiro.filter.KickoutSessionFilter.setShiroSessionRepository"/>
<property name="arguments" ref="jedisShiroSessionRepository"/>
</bean>
<!-- 继承自AuthorizingRealm的自定义Realm,即指定Shiro验证用户登录的类为自定义的ShiroDbRealm.java -->
<!-- 授权 认证 -->
<bean id="sampleRealm" class="com.sojson.core.shiro.token.SampleRealm" ></bean>
<!-- Session Manager -->
<bean id="sessionManager" class="org.apache.shiro.web.session.mgt.DefaultWebSessionManager">
<!-- 相隔多久检查一次session的有效性 -->
<property name="sessionValidationInterval" value="1800000"/>
<!-- session 有效时间为半小时 (毫秒单位)-->
<property name="globalSessionTimeout" value="1800000"/>
<property name="sessionDAO" ref="customShiroSessionDAO"/>
<!-- session 监听,可以多个。 -->
<property name="sessionListeners">
<list>
<ref bean="customSessionListener"/>
</list>
</property>
<!-- 间隔多少时间检查,不配置是60分钟 -->
<property name="sessionValidationScheduler" ref="sessionValidationScheduler"/>
<!-- 是否开启 检测,默认开启 -->
<property name="sessionValidationSchedulerEnabled" value="true"/>
<!-- 是否删除无效的,默认也是开启 -->
<property name="deleteInvalidSessions" value="true"/>
<!-- 会话Cookie模板 -->
<property name="sessionIdCookie" ref="sessionIdCookie"/>
</bean>
<!-- session 创建、删除、查询 -->
<bean id="jedisShiroSessionRepository" class="com.sojson.core.shiro.cache.JedisShiroSessionRepository" >
<property name="jedisManager" ref="jedisManager"/>
</bean>
<!--
自定义角色过滤器 支持多个角色可以访问同一个资源 eg:/home.jsp = authc,roleOR[admin,user]
用户有admin或者user角色 就可以访问
-->
<!-- 认证数据库存储-->
<bean id="shiroManager" class="com.sojson.core.shiro.service.impl.ShiroManagerImpl"/>
<bean id="login" class="com.sojson.core.shiro.filter.LoginFilter"/>
<bean id="role" class="com.sojson.core.shiro.filter.RoleFilter"/>
<bean id="permission" class="com.sojson.core.shiro.filter.PermissionFilter"/>
<bean id="simple" class="com.sojson.core.shiro.filter.SimpleAuthFilter"/>
<!-- Shiro主过滤器本身功能十分强大,其强大之处就在于它支持任何基于URL路径表达式的、自定义的过滤器的执行 -->
<!-- Web应用中,Shiro可控制的Web请求必须经过Shiro主过滤器的拦截,Shiro对基于Spring的Web应用提供了完美的支持 -->
<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
<!-- Shiro的核心安全接口,这个属性是必须的 -->
<property name="securityManager" ref="securityManager" />
<!-- 要求登录时的链接(可根据项目的URL进行替换),非必须的属性,默认会自动寻找Web工程根目录下的"/login.jsp"页面 -->
<property name="loginUrl" value="/u/login.shtml" />
<!-- TODO 待提取 -->
<!-- 登录成功后要跳转的连接(此属性可能用不到,因为可以在登录成功后的处理逻辑在LoginController里硬编码为main.jsp) -->
<property name="successUrl" value="/" />
<!-- 用户访问未对其授权的资源时,所显示的连接 -->
<property name="unauthorizedUrl" value="/?login" />
<!-- filterChainDefinitions:Shiro连接约束配置,即过滤链的定义 -->
<!-- 此处可配合这篇文章来理解各个过滤连的作用http://blog.csdn.net/jadyer/article/details/12172839 -->
<!-- 下面value值的第一个'/'代表的路径是相对于HttpServletRequest.getContextPath()的值来的 -->
<!-- anon:它对应的过滤器里面是空的,什么都没做,这里.do和.jsp后面的*表示参数,比方说login.jsp?main这种 -->
<!-- authc:该过滤器下的页面必须验证后才能访问,它是Shiro内置的一个拦截器org.apache.shiro.web.filter.authc.FormAuthenticationFilter -->
<!-- 初始配置,现采用自定义 -->
<!-- <property name="filterChainDefinitions" >-->
<!-- <value>-->
<!-- /** = anon-->
<!-- /page/login.jsp = anon-->
<!-- /page/register/* = anon-->
<!-- /page/index.jsp = authc-->
<!-- /page/addItem* = authc,roles[数据管理员]-->
<!-- /page/file* = authc,roleOR[普通用户,数据管理员]-->
<!-- /page/listItems* = authc,roleOR[数据管理员,普通用户]-->
<!-- /page/showItem* = authc,roleOR[数据管理员,普通用户]-->
<!-- /page/updateItem*=authc,roles[数据管理员]-->
<!-- </value>-->
<!-- </property>-->
<!-- 读取初始自定义权限内容-->
<property name="filterChainDefinitions" value="#{shiroManager.loadFilterChainDefinitions()}"/>
<property name="filters">
<util:map>
<entry key="login" value-ref="login"></entry>
<entry key="role" value-ref="role"></entry>
<entry key="simple" value-ref="simple"></entry>
<entry key="permission" value-ref="permission"></entry>
<entry key="kickout" value-ref="kickoutSessionFilter"></entry>
</util:map>
</property>
</bean>
<!-- Shiro生命周期处理器-->
<!-- 保证实现了Shiro内部lifecycle函数的bean执行 -->
<bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor" />
</beans>