MyEclipse中Spring Security 3.0.3无废话配置(第一章)。
第一件事,下载中文说明文档,搜索一下就能找到。
第二件事,找到官方原版英文说明文档,搜索一下就能找到。
第三件事,需要注意的问题:
1.请使用MyEclipse 自带的Spring 3与Spring Security 3(以下简称SS3),我的MyEclipse是8.6,自带的版本是SS3.0.3。
2.登录的表单用户名必须是j-username,密码必须是j-password,表单的action必须是"/你的项目/j_spring_security_check",这里是否可以定制,我不清楚。
3.MyEclise 8.6自带的Hibernate与Spring与SS3之间没有任何Jar包冲突,出现问题请不要怀疑Jar包的问题。(至少我的目前为止没有任何冲突)
4.注意头文件,Spring的头文件是:
<?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-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsdhttp://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"></beans>
<?xml version="1.0" encoding="UTF-8"?><beans:beans xmlns="http://www.springframework.org/schema/security"xmlns:beans="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"></beans:bean>
<!--Spring的ApplicationContext 载入 --><listener><listener-class>org.springframework.web.util.Log4jConfigListener</listener-class></listener><listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener><context-param><param-name>contextConfigLocation</param-name><param-value>classpath:applicationContext.xml</param-value></context-param><!-- SpringSecurity filter--><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>
<import resource="applicationContext-security.xml"/>
<http auto-config='true'> <intercept-url pattern="/**" access="ROLE_USER" /></http>
<authentication-manager><authentication-provider><user-service><user name="jimi" password="jimispassword" authorities="ROLE_USER, ROLE_ADMIN" /><user name="bob" password="bobspassword" authorities="ROLE_USER" /></user-service></authentication-provider></authentication-manager>
<http auto-config='true' access-denied-page="/common/403.jsp"><intercept-url pattern="/css/**" filters="none" /><intercept-url pattern="/images/**" filters="none" /><intercept-url pattern="/login.jsp*" access="IS_AUTHENTICATED_ANONYMOUSLY" /> <form-login login-page='/login.jsp' /><intercept-url pattern="/**" access="ROLE_USER" /> /></http>