我有类似的问题。如果我的最终操作是通过表单提交调用的,我总是会收到一条错误消息,指出对话已经关闭或过期。
当然,如果你没有完成对话,内存资源是不会被释放的。您可以在 strut2 对话插件站点中获得有关此的一些信息:https ://code.google.com/p/struts2-conversation/wiki/UsageGuide#Memory_Management
在那里可以看到可以设置一些与会话线程的过期时间和可以同时使用的数量相关的参数:
<!-- monitoring frequency in milliseconds -->
<constant name="conversation.monitoring.frequency" value="300000"/>
<!-- idle conversation timeout in milliseconds -->
<constant name="conversation.idle.timeout" value="28800000"/>
<!-- max instances of a conversation -->
<constant name="conversation.max.instances" value="20"/>
<!-- number of timeout monitoring threads -->
<constant name="conversation.monitoring.thread.pool.size" value="20"/>
无论如何,我解决了这个问题,在最后一个动作中添加了一个重定向结果,该动作调用了一个包含 @EndConversation 标记的动作。在其中我只是设置了我想成为最后一个的结果。对话字段变量仍然设置正确且可用。
@ConversationAction(conversations = "form")
@Action(value="formSecondLast", results={@Result(name=SUCCESS, type = "redirect", location="formLast")})
public String formSecondLast() throws Exception {
//Here goes the code you want it to manipulate the conversation field data.
//Maybe save to the database or send it to the business tier.
return SUCCESS;
}
@EndConversation(conversations = "form")
@Action(value="formLast", results={@Result(name=SUCCESS, location="/jsp/form-end.jsp")})
public String formEnd() throws Exception {
// This is a dummy action that does not do anything.
// It is called just after formSecondLast ends and sends the user the jsp page.
return SUCCESS;
}