日期:2014-05-16 浏览次数:20553 次

<filter> <filter-name>springSecurityFilterChain</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> </filter> <filter-mapping> <filter-name>springSecurityFilterChain</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
<?xml version="1.0" encoding="UTF-8"?>
<b:beans xmlns="http://www.springframework.org/schema/security"
xmlns:b="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.0.xsd">
<!-- <global-method-security pre-post-annotations="enabled" /> -->
<!-- access-denied-page配置访问失败页面 -->
<http auto-config="true" access-denied-page="/accessDenied.htm">
<!-- 不要过滤图片等静态资源,其中**代表可以跨越目录,*不可以跨越目录。 -->
<intercept-url pattern="/**/*.jpg" filters="none" />
<intercept-url pattern="/**/*.png" filters="none" />
<intercept-url pattern="/**/*.gif" filters="none" />
<intercept-url pattern="/**/*.css" filters="none" />
<intercept-url pattern="/**/*.js" filters="none" />
<intercept-url pattern="/login.htm*" filters="none"/>
<!-- <intercept-url pattern="/index.htm" access="ROLE_USER,ROLE_ADMIN"/>
<intercept-url pattern="/header.htm" access="ROLE_USER,ROLE_ADMIN"/>
<intercept-url pattern="/left.htm" access="ROLE_USER,ROLE_ADMIN"/> -->
<intercept-url pattern="/**" access="ROLE_USER"/>
<!-- 配置登录页面 -->
<form-login login-page="/login.htm"
default-target-url="/" authentication-failure-url="/login.htm?error=true"
login-processing-url="/springSecurityLogin"/>
<!--"记住我"功能,采用持久化策略(将用户的登录信息存放在数据库表中) -->
<!-- <remember-me/> -->
<!-- 用户退出的跳转页面 -->
<logout logout-success-url="/login.htm" invalidate-session="true"
logout-url="/logout" />
<!-- 会话管理,设置最多登录异常,error-if-maximum-exceeded = false为第二次登录就会使前一个登录失效 -->
<session-management invalid-session-url="/error/errorPage.jsp">
<concurrency-control max-sessions="1" error-if-maximum-exceeded="false" />
</session-management>
<!--添加自定义的过滤器 放在FILTER_SECURITY_INTERCEPTOR之前有效 -->
<custom-filter ref="customFilterSecurityInterceptor" before="FILTER_SECURITY_INTERCEPTOR" />
</http>
<!-- 配置认证管理器 -->
<authentication-manager alias="authenticationManager">
<authentication-provider user-service-ref="customUserDetailsService">
<password-encoder hash="md5"/>
<!-- <jdbc-user-service data-source-ref="dataSource"/> -->
</authentication-provider>
</authentication-manager>
</b:beans>