如何在没有重启应用服务器的情况下清除struts2会话属性中的数据

时间:2016-04-06 06:14:33

标签: java jsp session struts2

在我的应用程序中,我使用的是struts2和hibernate。在我的一个服务类中,我使用struts2 session来设置属性,并在我的jsp中获得该属性。 这是java类部分:

 Map fileInformation = ActionContext.getContext().getSession();
 fileInformation.put("checkFirstPart"," Hello ");

这是jsp scriptlet:

<%
     Map recordedData2=ActionContext.getContext().getSession();
     String checkFirstPart = (String)recordedData2.get("checkFirstPart");
%>
<%
     if (checkFirstPart != null)
     out.println(checkFirstPart);
%>

问题是每次运行我的项目时,会话都不清楚,并显示所有先前的消息,直到我重新启动应用程序服务器。 我也使用了它,但没用:

fileInformation.clear;

请帮忙。

1 个答案:

答案 0 :(得分:1)

获取attribues后将此代码放入jsp页面:

recordedData2.clear();

我认为这将解决您的问题