簡體   English   中英

java struts1:使用一個ActionForm從一個動作到另一個動作

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

就像我在標題中所說的,我有兩個動作( 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>

重定向的第一個動作方法

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");

}

第二行動方法(收件人):

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();   }

**這是問題所在,第二個動作會從第一個動作中得到一個空表格**我該如何解決這個問題?

是的,另一種方法是將重定向屬性值更改為false <<轉發名稱=“ UpdateStudent” path =“ / updateStudent.do” redirect =“ false” />

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM