解决方案 »

  1.   

    页面无刷新的话
    建议楼主用jquery中的ajax吧
      

  2.   

    ajax也是在提交请求的时候,拦截过滤我想实现当页面没有请求的时候(没有请求就无法调用拦截过滤),由页面做一个计时,超时跳转相当于,超时之后,点击页面空白处,也可以实现超时跳转
      

  3.   

    首先保证设置session的过期时间
    然后在页面上进行定时无状态刷新,判断session中(比如)用户名,如果为空则跳转,这样的话不需要点鼠标也可以自动跳转
    给你个demo <%@ page contentType="text/html; charset=UTF-8" language="java"
    pageEncoding="UTF-8"%>
    <html>
    <head>
    <link rel="StyleSheet" href="<%=basePath %>/newtouch/default/css/tab.css"
    type="text/css" />
    <script type="text/javascript"
    src="<%=basePath%>/newtouch/js/jquery-1.3.2.min.js"></script>
    <script type="text/javascript" src="<%=basePath %>/newtouch/js/tab.js"></script>
    <script type="text/javascript">
    /**
     * 定时刷新div 并监测session如果发生变化中则跳转到登录页面
     */
    setInterval(function(){
    $("#dingshi").load(location.href+" #dingshi>*","");
    var un = $("#user_namejc").val();
    if(un==""){
          location.href = '<%=basePath%>/login';
    }
    }, 1000);
    </script>
    </head>
    <body>
    <div id="dingshi" style="display:none">
    <input type="text" id="user_namejc" value="${userNo}">
         </div>
    </body>
    </html>
      

  4.   

    我用的是SSH框架l配置的监视器:  1.web.xml文件      <listener-class>
          com.dwg.FilterAndListener.SessionListener
        </listener-class>
    2.写的类 :package com.dwg.FilterAndListener;import javax.servlet.http.*;
    public class SessionListener implements HttpSessionListener {
    //private ServletContext context = null;//servlet上下文
    public void sessionCreated(HttpSessionEvent event) {
      //因为创建session没有动作,所以这个方法就可以不写了
    System.out.println("----创建session-----");  
     }
      public void sessionDestroyed(HttpSessionEvent event) {
        //监听session,当session过期后,就转道登陆页面
      System.out.println("----session失效-----"); 
    //    if (context == null) 
    //      storeInServletContext(event);
    }
    //    private void storeInServletContext(HttpSessionEvent event) {
    //    HttpSession session = event.getSession();
    //    context = session.getServletContext();
    //    context.setAttribute("sessionCounter", this);
    //}
    }