在我的应用程序中,我使用 struts2 和 hibernate。在我的一个服务类中,我使用 struts2 session 设置一个属性,并在我的 jsp 中获取该属性,如下所示。 这是java类部分:
Map fileInformation = ActionContext.getContext().getSession();
fileInformation.put("checkFirstPart"," Hello ");
这是 jsp 脚本:
<%
Map recordedData2=ActionContext.getContext().getSession();
String checkFirstPart = (String)recordedData2.get("checkFirstPart");
%>
<%
if (checkFirstPart != null)
out.println(checkFirstPart);
%>
问题是每次我运行我的项目时, session 都不清楚并显示所有以前的消息,直到我重新启动应用程序服务器。 我也用过这个,但没有用:
fileInformation.clear;
请帮忙。
最佳答案
获取属性后将此代码放入您的jsp页面中:
recordedData2.clear();
我认为这会解决你的问题
关于java - 如何在不重启应用服务器的情况下清除struts2 session 属性中的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36442946/