Apache Tomcat 重新启动会导致 Java 中的会话清除并且会话保留在 JSP 页面上
我在我的jsp页面中编写了一个jsp重定向,如下所示
<s:if test="#session.Doctor = true ">
<script type="text/javascript">
top.location.href = "dashboard";
<s:property value="#session.Doctor" />
</script>
</s:if>
当我重新启动Tomcat时,标签在我的jsp页面中打印true
。但我在 struts 中编写了一个拦截器,它检查会话 System.out.println(session.get("doctorLogin")+"test");
并打印 null
当我重新启动页面时。这里我可以理解,当我重新启动tomcat时,会话在java中被清除,当我重新启动tomcat时,会话在jsp中保留。有人知道为什么这个会话在java页面中被清除而在重新启动tomcat时在jsp页面中没有被清除吗?有人有想法吗?
我使用 struts2、hibernate 和 tomcat6 作为服务器
谢谢。
I have written a jsp redirect in my jsp page like this
<s:if test="#session.Doctor = true ">
<script type="text/javascript">
top.location.href = "dashboard";
<s:property value="#session.Doctor" />
</script>
</s:if>
The tag prints true
in my jsp page when I restart Tomcat. But I have written a interceptor in struts which checks the session System.out.println(session.get("doctorLogin")+"test");
and it prints null
when I restart the page. Here I could understand that the session is cleared in java when I restart tomcat and session persist in jsp when I restart tomcat. Do anybody have an idea about how this why this session is cleared in java page and why it doesn't in jsp page when restart the tomcat. Does anybody have an idea?
I am using struts2, hibernate and tomcat6 as server
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
if 标签中的测试是否损坏?
在java中,表达式
session.Doctor = true
不会检查session.Doctor的值。相反,它为 session.Doctor分配值 true。尝试使用
(注意第二个等于)Is the test in the if tag broken?
in java, the expression
session.Doctor = true
doesn't check the value of session.Doctor. Rather, it assigns the value true to session.Doctor.Try using
<s:if test="#session.Doctor == true ">
(note the second equals)