Il y a un truc que je ne comprend pas bien avec Struts. Lorsqu'on déclare un formulaire, il est nécessaire d'écrire une classe qui hérite de ActionForm. Il faut ensuite déclarer ce bean dans le fichier struts-config.xml avec la balise <form-beans>. Jusque là rien d'extraordinaire. C'est la suite que je ne comprends pas bien.
Prenons le cas suivant :
Ce que je ne comprends pas, c'est pourquoi "formbean" est appelé dans l'action de la page qui permet d'accéder au formulaire (accueil.jsp) et non pas dans l'action qui permet d'accéder au formulaire. En clair, pourquoi fait-on ce qui est écrit ci-dessus et non pas ceci (ce qui paraitrait plus logique à mes yeux) :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 <form-beans> <form-bean name="formbean" type="beans.FormulaireBean"/> </form-beans> <action-mappings> <action path="/accueil" parameter="/accueil.jsp" name="formbean" type="org.apache.struts.actions.ForwardAction" /> <action path="/formulaire" parameter="/formulaire.jsp" type="org.apache.struts.actions.ForwardAction" /> </action-mappings>
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 <form-beans> <form-bean name="formbean" type="beans.FormulaireBean"/> </form-beans> <action-mappings> <action path="/accueil" parameter="/accueil.jsp" type="org.apache.struts.actions.ForwardAction" /> <action path="/formulaire" parameter="/formulaire.jsp" name="formbean" type="org.apache.struts.actions.ForwardAction" /> </action-mappings>
Partager