检索struts2中多个操作类的操作消息

时间:2015-01-20 05:47:34

标签: struts2

我正在使用struts2和hibernate开发一个java项目 我有一个超级动作类将其命名为ProjAction,在该项目管理中,每个事件都会遇到主要的超级类。 在将数据保存到超级操作类并提供结果后,我将一个子操作类命名为saveDataAction。 因此,对于超级动作类,我可以使用struts2配置文件中的商店拦截器为其各自的动作类结果显示动作消息。我使用了operationMode作为' AUTOMATIC'

现在要避免刷新问题我有一个动作类名称,它是ProjRedirectAction。因此,在此操作类中,我无法在保存数据后显示/检索操作消息

任何人都可以告诉我如何使用商店拦截器访问ProjRedirectAction类中的操作消息。或者有没有办法向struts2的多个动作类显示动作消息。

    public class SuperAction extends ActionSupport {
    public String getData() {
    //implementation for showing the data in the jsp page
    //the result is always redirect to some default.jsp
    return SUCCESS;
    }
    //private method which accessed by its child class for redirecting to superclass
   public String nextCall() {
   //few implementation done after that it calls the getData() method
   return getData();
   }
   }

//Child Class implementaion for ex saving records in db
public class ChildAction extends SuperAction {
public String saveData() {
//saving data to db and then calling the return nextCall method of superACtion class
return nextCall();
}
}

//早些时候我有这个实现,之所以在我的项目中添加一个动作类是为了避免刷新问题(在刷新相同的值时插入到DB)所以我添加了一个名为RedirectAction的动作类< / p>

// RedirectACtion类实现

public class RedirectAction {
public String execute() {
//this method is having same implementation as the method getData() of SuperAction class includes
return SUCCESS;
}
}

// struts.xml config

<package name="default" extends="struts-default" namespace="/">
//SuperACtion class result
<action name="*Super" method="{1}" class="com.action.SuperAction">
<interceptor-ref name="store">
<param name="operationMode">AUTOMATIC</param>
</interceptor-ref>
<result name="SUCCESS" type="redirectAction">executeRedirect</result>
</action>

//ChildACtion class result
<action name="*Child" method="{1}" class="com.action.ChildAction">
<interceptor-ref name="store">
<param name="operationMode">AUTOMATIC</param>
</interceptor-ref>
<result name="SUCCESS" type="redirectAction">executeRedirect</result>
</action>

//RedirectACtion class result
<action name="*Redirect" method="{1}" class="com.action.RedirectAction">
<interceptor-ref name="store">
<param name="operationMode">AUTOMATIC</param>
</interceptor-ref>
<result name="SUCCESS" type="tiles">Default.jsp</result>
</action>

这个问题我没有找到任何解决方案,任何帮助都非常适合 谢谢

0 个答案:

没有答案
相关问题