2012-06-07 26 views
0

我的代码动作变量的值是这样的:如何设置从JSP

public class CustoTypeAction extends ActionSupport{ 
    private ResultDto resultDto; 
    //setter & getter resultDto 
} 

配置:

<action name="listCustoType" method="listCustomerType" class="custoType"> 
    <result name="success">listCustoType.jsp</result> 

我怎样才能resultDto值从页面加载JSP设置为空?我应该使用什么struts标签?

+0

你为什么要这么做? –

+0

默认情况下它将为空,为什么你认为它不为空? – mprabhat

+0

因为我想只显示一次,当用户重新加载页面再次,对象= NULL –

回答

0

据我所知,你必须实现Preparable接口。它在​​方法之前执行。

http://struts.apache.org/2.1.6/struts2-core/apidocs/com/opensymphony/xwork2/Preparable.html

如果你想显示的对象只有一次,而且必须走了用户重新加载页面后,您必须使用会话。如果文件已被显示,您可以更改会话中的值,以防下一次重新加载时显示该值。

你可以看到的例子与会话从这里工作:

http://www.roseindia.net/struts/struts2/struts2-login.shtml