spring security除通过form-login的熟悉指定登陆还可以通过entry-point-ref 指定登陆入口。具体配置如下:

<?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:security="http://www.springframework.org/schema/security"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security.xsd">
<!-- entry-point-ref指定登录入口 -->
<security:http entry-point-ref="authEntryPoint">
<security:logout delete-cookies="JSESSIONID" />
<security:intercept-url pattern="/login*.jsp*"
access="IS_AUTHENTICATED_ANONYMOUSLY" />
<security:intercept-url pattern="/**" access="ROLE_USER" />
<!-- 添加自己定义的AuthenticationFilter到FilterChain的FORM_LOGIN_FILTER位置 -->
<security:custom-filter ref="authenticationFilter" position="FORM_LOGIN_FILTER"/>
</security:http>
<!-- AuthenticationEntryPoint,引导用户进行登录 -->
<bean id="authEntryPoint" class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint">
<property name="loginFormUrl" value="/login.jsp">
</property>
</bean> <!-- 认证过滤器 -->
<bean id="authenticationFilter"
class="org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter">
<property name="authenticationManager" ref="authenticationManager" />
<property name="usernameParameter" value="username"/>
<property name="passwordParameter" value="password"/>
<property name="filterProcessesUrl" value="/login.do" />
</bean> <security:authentication-manager alias="authenticationManager">
<security:authentication-provider user-service-ref="userDetailsService">
<security:password-encoder hash="md5"></security:password-encoder>
</security:authentication-provider>
</security:authentication-manager>
<bean id="userDetailsService" class="org.springframework.security.core.userdetails.jdbc.JdbcDaoImpl">
<property name="dataSource" ref="dataSource"></property>
</bean> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="com.mysql.jdbc.Driver"></property>
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/security"></property>
<property name="user" value="root"></property>
<property name="password" value="root"></property>
<property name="acquireIncrement" value="5"></property> <!-- 当连接池中的连接用完时,C3P0一次性创建新连接的数目2 -->
<property name="initialPoolSize" value="10"></property> <!-- 初始化时创建的连接数,必须在minPoolSize和maxPoolSize之间 -->
<property name="minPoolSize" value="5"></property>
<property name="maxPoolSize" value="20"></property>
<!-- 最大空闲时间,超过空闲时间的连接将被丢弃
[需要注意:mysql默认的连接时长为8小时(28800)【可在my.ini中添加 wait_timeout=30(单位秒)设置连接超时】,这里设置c3p0的超时必须<28800]
-->
<property name="maxIdleTime" value="300"></property>
<property name="idleConnectionTestPeriod" value="60"></property> <!-- 每60秒检查连接池中的空闲连接 -->
<property name="maxStatements" value="20"></property> <!-- jdbc的标准参数 用以控制数据源内加载的PreparedStatement数量,但由于预缓存的Statement属 于单个Connection而不是整个连接 -->
</bean>
</beans>

本文配置摘自:http://haohaoxuexi.iteye.com/blog/2161648

最新文章

  1. SQL Server技术问题之游标优缺点
  2. MIT算法导论——第四讲.Quicksort
  3. 创建触发器在表中播入数据时ID自动增长
  4. android 权限总结
  5. CodeForces 706E Working routine
  6. kbhit()的三个测试
  7. 基于require+knockout的webapp结构设计
  8. (转)spring aop(下)
  9. Zk 集群概念
  10. win7下Oracle库impdp导入dmp
  11. 知识点:synchronized 原理分析
  12. Python开发【第六篇】:面向对象
  13. AndroidStudio_TextView
  14. Local policy - User rights assignment 对照表
  15. 可供选择CSS框架
  16. Codeforces Round #350 (Div. 2) C. Cinema 水题
  17. SpringData_PagingAndSortingRepository接口
  18. Ext文本输入框:Ext.form.TextField属性汇总(转) (
  19. java多线程之ReentrantLock
  20. android应用js

热门文章

  1. 3682: Phorni 后缀平衡树 线段树
  2. 4712: 洪水 基于链分治的动态DP
  3. 潭州课堂25班:Ph201805201 redis第四课 (课堂笔记)
  4. Oracle 删除重复数据只留一条(转)
  5. chrome插件开发.在content_script异步加载页面后, 如何进行JS通信与调用的问题
  6. HTML 5 断点续上传
  7. How to change the implementation (detour) of an externally declared function
  8. reveal 使用注意事项
  9. Spring---面向切面编程(AOP模块)
  10. IIS6 2.0 4.0 冲突解决 &#39;c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\xxx&#39; -- &#39;Access is denied. &#39;