web.xml中配置session超时过滤器
来源:互联网 发布:c windows syswow32 编辑:程序博客网 时间:2024/04/30 01:08
一、首先在web.xml里配置如下信息:(数字10代表10分钟)
<session-config> <session-timeout>10</session-timeout> </session-config>
二、做一个过滤器,实现Filter接口,对指定路径下的请求进行session的失效验证,如失效则跳转到登录页面:
public class RequestFilter implements Filter {public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { //在这里判断session是否已失效,如已失效则重定向到登录页面。 User user = (User)request.getSession().getAttribute("user"); if(user == null) { response.sendRedirect(request.getContextPath()+"/login.jsp"); return; } } public void init(FilterConfig config) throws ServletException { } public void destroy() { }}
三、在web.xml里配置过滤器:
<filter> <filter-name>requestFilter</filter-name> <filter-class>com.xxx.RequestFilter</filter-class> </filter> <filter-mapping> <filter-name>requestFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
当用户再次操作向服务端发起请求时执行。
- web.xml中配置session超时过滤器
- web.xml配置Session超时时间设置
- web.xml配置Session超时时间注意的单位问题
- web.xml配置Session超时时间注意的单位问题
- web.xml配置Session超时时间注意的单位问题
- web.xml配置Session超时时间注意的单位问题
- web.xml配置Session超时时间注意的单位问题
- 在web.xml中配置过滤器
- web.xml中配置乱码过滤器
- web.xml 过滤器配置
- 在web.xml中配置session周期
- web.xml中配置session属性
- web.xml中配置session属性
- websphere中的会话超时设置 和 web应用中web.xml中session-timeout关系
- websphere中的会话超时设置 和 web应用中web.xml中session-timeout关系
- web.xml配置session
- servlet过滤器 web.xml配置
- web.xml中配置spring字符编码过滤器
- Javascript 面向对象编程
- iptables nat-让linux做为路由器,实现局域网访问外网
- FFMpeg havlenapetr工程编译
- android java.net.UnknownHostException: Unable to resolve host "...": No address associated 错误
- IOS 如何选择delegate、notification、KVO?
- web.xml中配置session超时过滤器
- 人要做自己 才是最重要的
- sql中 with rollup 、with cube、grouping 统计函数用法
- WinCE中文显示乱码的解决办法
- 贪心算法
- lua程序设计第二版 读书笔记(22-23章)
- Java基础复习:Random类与UUID类
- oracle11g从11.2.0.3.0升级到11.2.0.3.6操作步骤(二)
- 根文件系统及Busybox简介