[英]Session variable set in index.jsp returns null when accessed 3rd or 4th time by javascript in others jsp's
The project is using Spring Framework. 该项目正在使用Spring Framework。
The flow is as follows : 流程如下:
Uptil here there is no issue. 直到这里没有问题。 But in i click the on other links like "/test.jsp", the javascript in "test.jsp" is returning null for 但是在我单击其他链接,例如“ /test.jsp”时,“ test.jsp”中的javascript返回null
var countryCode = '<%= session.getAttribute("countryCode") %>'; var countryCode ='<%= session.getAttribute(“ countryCode”)%>';;
Similarly if i click on "/index.jsp" it is redirecting me to "country.html" because 同样,如果我单击“ /index.jsp”,它会将我重定向到“ country.html”,因为
coun =(String) objectSession.getAttribute("countryCode"); coun =(String)objectSession.getAttribute(“ countryCode”);
in the scriptlet is null i guess. 我猜在scriptlet中为null。
I was using the response.SendRedirect() which was creating a new session on every attempt. 我正在使用response.SendRedirect(),它在每次尝试时都创建一个新会话。 Now i am using controller only but instead of redirect used ModelAndView to get to the desired page. 现在我只使用控制器,而不是使用ModelAndView重定向到所需页面。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.