<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!--加载Spring XML配置文件 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:securityConfig.xml
</param-value>
</context-param>
<!-- Spring Secutiry3.1的过滤器链配置 -->
<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>
<!-- Spring 容器启动监听器 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
<?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.1.xsd">
<!--登录页面不过滤 -->
<http pattern="/login.jsp" security="none"/>
<http access-denied-page="/accessDenied.jsp">
<form-login login-page="/login.jsp"/>
<!--访问/admin.jsp资源的用户必须具有ROLE_ADMIN的权限 -->
<intercept-url pattern="/admin.jsp" access="ROLE_ADMIN"/>
<!--访问/**资源的用户必须具有ROLE_USER的权限 -->
<intercept-url pattern="/**" access="ROLE_USER"/>
<session-management>
<concurrency-control max-sessions="1" error-if-maximum-exceeded="false"/>
</session-management>
</http>
<authentication-manager>
<authentication-provider>
<user-service>
<user name="john" password="john" authorities="ROLE_USER" />
<user name="admin" password="admin" authorities="ROLE_USER, ROLE_ADMIN" /> <user name="guest" password="guest" authorities="ROLE_GUEST" />
</user-service>
</authentication-provider>
</authentication-manager>
</b:beans>
<body>
<form action="j_spring_security_check" method="POST">
<table>
<tr>
<td>用户:</td>
<td><input type='text'name='j_username'></td>
</tr>
<tr>
<td>密码:</td>
<td><input type='password'name='j_password'></td>
</tr>
<tr>
<td><input name="reset"type="reset"></td>
<td><input name="submit"type="submit"></td>
</tr>
</table>
</form>
</body>
<body> 您的访问被拒绝,无权访问该资源!<br> </body>
<body> 欢迎来到管理员页面. <br> </body>
<body>
这是首页,欢迎<sec:authentication property="name"/>!<br>
<a href="admin.jsp" rel="external nofollow" >进入admin页面</a>
<a href="other.jsp" rel="external nofollow" >进入其它页面</a>
</body>
<user name="john" password="john" authorities="ROLE_USER" /> <user name="admin" password="admin" authorities="ROLE_USER, ROLE_ADMIN" />
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有