这是我的代码部分
Jsp:
<script src="../../js/jquery-1.11.1.min.js"></script>
<script src="../../js/jquery.mobile-1.4.2.min.js"></script>
$("#submit").click( function(){
$('#pairingForm').attr('data-ajax','false');
$("#pairingForm").submit();
});
<form action = "pairing" id = "pairingForm">
<input type = "hidden" name = "FromPairing" value = "Y">
<%
request.getSession().setAttribute("qoo", "qoo");
// and I still tried to use this
//session.setAttribute("qoo","qoo");
%>
</form>
Java:
@RequestMapping("/pairing")
public ModelAndView pairing(HttpServletRequest request) throws Exception {
HttpSession session = request.getSession();
System.out.println(" FromPairing = " + request.getParameter("FromPairing"));
// return Y here
System.out.println("qoo = " + session.getAttribute("qoo"));
//return null here
}
当我使用IP作为域名时,它可以找到。但是当它来到域名时,我会得到不同的会话ID(在调试模式下找到它)。也许是因为服务器会将Http帖子重定向给我(我不确定),它会创建一个新的会话。所以我的问题是如何确保我可以通过重定向从另一台服务器获得相同的会话,除了在url中传递会话?