简体   繁体   English

java struts1:使用一个ActionForm从一个动作到另一个动作

[英]java struts1: forward from action to action with One ActionForm

Like I said in the title , I have two actions ( studentAction , UpdateStudentAction ) One , action form : studentForm and the struts-config like : 就像我在标题中所说的,我有两个动作( studentActionUpdateStudentAction ),一个动作形式是: studentForm和struts-config像这样:

<action path="/student"
    type="action.StudentAction"
    name="studentForm"
    scope="request"
    validate="true"
    input="tiles.etudiant"
    parameter="dispatch">       
    <forward name="UpdateStudent"  path="/updateStudent.do" redirect="true" />  
</action>

<action path="/updateStudent"
    type="action.UpdateStudentAction"
    scope="request"
    name="studentForm"
    input="tiles.modifierEtudiant"
    parameter="dispatch">
</action>

First action method to redirect 重定向的第一个动作方法

public ActionForward onModifier(
        ActionMapping mapping,
        ActionForm form,
        javax.servlet.http.HttpServletRequest request,
        javax.servlet.http.HttpServletResponse response)
        throws DatabaseFailureException {       
StudentForm studentForm=(StudentForm)form;
return mapping.findForward("UpdateStudent");

} }

The Second Action method (recipient) : 第二行动方法(收件人):

public ActionForward onInitialiser(
        ActionMapping mapping,
        ActionForm form,
        javax.servlet.http.HttpServletRequest request,
        javax.servlet.http.HttpServletResponse response)
        throws DatabaseFailureException {

        StudentForm studentForm=(StudentForm)form;
        //etudiantForm.setIdEtudiantSelectionne("1");
        List listeCriteres=new ArrayList();
        listeCriteres.add(new SearchBean(new Etudiant().HQL_ID_ETUDIANT(), etudiantForm.getIdEtudiantSelectionne()));   etudiantForm.setListeEtudiants(getReferenceDataService().findListBoParCriteres(Etudiant.class, listeCriteres));

        return mapping.getInputForward();   }

**Here is the probleme , the second action get an empty form from the first one ** how can i fix this problem ?! **这是问题所在,第二个动作会从第一个动作中得到一个空表格**我该如何解决这个问题?

是的,另一种方法是将重定向属性值更改为false <<转发名称=“ UpdateStudent” path =“ / updateStudent.do” redirect =“ false” />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM