首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

SpringSecurity备忘配备

2012-10-06 
SpringSecurity备忘配置1.定义登录后的首页action.do,该action决定了用户登录成功后的具体初始化内容。?2.

SpringSecurity备忘配置

1.定义登录后的首页action.do,该action决定了用户登录成功后的具体初始化内容。

?

2.在根目录定义index.jsp页面,并设置为welcome-file-list首要引导页面。

?

3.index.jsp页面只做跳转操作,内容如下:

?

?

<%

response.setHeader("Cache-Control", "Private");

response.setDateHeader("Expires",

System.currentTimeMillis() + 864000000L);

response.sendRedirect("./index.do");

%>

?

?

-------------

?

意味着任何请求都跳转到 index.do,若没通过验证,则自动再会被拦截跳到配置的登录页面,登录成功后会index.do。

?

4.直接访问登录页面,向/j_spring_security_check发请求后。会跳转到默认的索引页面,例如 www.foo.com

? 即直接访问welcome-file-list中配置的页面,然而参考第三点的设置。

?

所以,我们也能实现用户直接访问登录页面,但成功后又能返回我们指定首页中去。

?

5.勿忘,除了导入SpringSecurity的配置XML文件,在web.xml中的

?

<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>

?

?

也是尤其重要的。

?

6.默认让请求都IS_AUTHENTICATED_REMEMBERED

?

这样可以让所以通过了验证或记录了验证权限的角色访问页面,不需要另外弄自定义登录权限了。

热点排行