2016-03-23 37 views
0

私はstrutsに2つのアプリケーションがあり、もう1つは春です。 strutsアプリケーションからは、モデルを返すajax呼び出しを通じてSpringアプリケーションコントローラを呼び出すリンクが1つあります。ajaxを使用したセッションタイムアウトの問題

strutsアプリケーションでセッションタイムアウトが20分あり、strutsアプリケーションでレンダリングされるスプリングアプリケーションのトランザクションを実行している間、strutsアプリケーションのセッションタイムアウトは同じままで、20分後にログアウトします。

strutsアプリケーションJSPページ。

<body> 
<div id="content"></div> 
</body> 
<script type="text/javascript"> 

    $(document).ready(function() { 
     var sessionId = '<%= sessionId %>' 

     $.ajax({ 
     type: "GET", 
     url: '/springapp/index.app?id='+sessionId, 
     data: "" , 
     success: function(response){ 
      $('#content').html(response); 
     }, 
     error: function(e){ 
     alert('Error: ' + e); 
     console.log(e) 
     } 
    }); 


    }); 
</script> 

スプリングアプリケーションコントローラ。

@RequestMapping(value = "/*.app", method = {RequestMethod.GET, RequestMethod.POST}) 
    public String jspController(ServletRequest req, ServletResponse res) throws exception { 
     LOGGER.debug("inside jspController() start"); 
     HttpServletRequest request = (HttpServletRequest) req; 
     String model = request.getRequestURI(); 
     if (model.endsWith("index.app")) { 
      String sessionKey = request.getParameter("employeeId"); 
      SpringStrutsHandshake springStrutsHandshake = securityDelegate.getUserId(sessionKey); 
      User user = userDelegate.getUserByEmployeeId(springStrutsHandshake.getUserId()); 
      user.setSessionKey(sessionKey); 
      request.setAttribute("USER", user); 
      model = "candidateList"; 
     } else { 
      model = model.substring(model.lastIndexOf("/") + 1, model.lastIndexOf(".")); 
     } 
     return model; 
    } 

レンダリングされた春のアプリケーションページにトランザクションがあるとタイムアウトの問題を解決する方法を教えてください。

答えて

0

strutsアプリケーションでセッションタイムアウトをしたくない場合は、セッションをアイドリング状態に保つだけで何もしないstrutsアプリケーションに定期的に(15分おきに)リクエストを送信し続けるのはなぜですか?春のアプリ呼び出しを返します。

それとも、動的にこの

request.getSession.setMaxInactiveInterval(60*60); //in seconds 
などのセッションタイムアウト時間を設定するためのメソッドを追加することができます
関連する問題