Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在Spring MVC中避免会话超时_Java_Spring_Jsp_Spring Mvc_Session - Fatal编程技术网

Java 在Spring MVC中避免会话超时

Java 在Spring MVC中避免会话超时,java,spring,jsp,spring-mvc,session,Java,Spring,Jsp,Spring Mvc,Session,我使用session变量传递所有必要的数据,当session过期时,所有数据都将丢失。我不希望它在特定jsp上过期,但在其他jsp会话中它可能会过期 我建议根据计时器连续向服务器发送请求,以避免特定jsp中的会话过期 我使用SpringMVC。如何在特定jsp上执行此操作 我尝试了以下代码,但我需要做的是在不使用映像的情况下向服务器发送请求: function keepMeAlive(imgName) { myImg = document.getElementById(imgName);

我使用session变量传递所有必要的数据,当session过期时,所有数据都将丢失。我不希望它在特定jsp上过期,但在其他jsp会话中它可能会过期

我建议根据计时器连续向服务器发送请求,以避免特定jsp中的会话过期

我使用SpringMVC。如何在特定jsp上执行此操作

我尝试了以下代码,但我需要做的是在不使用映像的情况下向服务器发送请求:

function keepMeAlive(imgName) {
   myImg = document.getElementById(imgName);
   if (myImg) myImg.src = myImg.src.replace(/?.*$/, '?' + Math.random());
}
window.setInterval("keepMeAlive('keepAliveIMG')", 100000);

<img id="keepAliveIMG" width="1" height="1" src="http://www.some.url/someimg.gif?" />
函数keepMeAlive(imgName){
myImg=document.getElementById(imgName);
如果(myImg)myImg.src=myImg.src.replace(/?*$/,“?”+Math.random());
}
setInterval(“keepMeAlive('keepAliveIMG')”,100000);
尝试使用ajax调用:

函数keepAlive(){
$.get(window.location.pathname,函数(数据){console.log(数据)});
}
设置间隔(keepAlive,100000)
function f(){
              var oRequest = new XMLHttpRequest();
var sURL = "http://"
         + "localhost:8080/sessionAlivecheck/"
         + "/example/newjsp.jsp";

oRequest.open("GET",sURL,false);
oRequest.setRequestHeader("User-Agent",navigator.userAgent);
oRequest.send(null);
//alert("hhh");
          }

          $(document).ready(function () {
  setInterval(f, 2000);
});