Bonjour,
Voila quand je lance mon formulaire dynamique fait avec struts
j'ai le message suivant :
Je ne comprends vraiment pas ce qu'il se passe.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 org.apache.jasper.JasperException: Exception in JSP: /formulaire.personne.jsp:30 27: 28: <body> 29: <html:form action="/main" name="frmPersonne" type="istia.st.struts.personne.PersonneDynaForm"> 30: nom : <html:text property="nom" size="20"/><br> 31: age : <html:text property="age" size="3"/><br> 32: <html:submit value="Envoyer"/> 33: </html:form> Stacktrace: org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:506) ... cause mère java.lang.NullPointerException org.apache.commons.beanutils.PropertyUtils.getSimpleProperty(PropertyUtils.java:1162) ...
Mon Struts config:
et enfin mon PersoDynaform:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd"> <struts-config> <form-beans> <form-bean name="frmPersonne" type="istia.st.struts.personne.PersonneDynaForm"> <form-property name="nom" type="java.lang.String" initial=" " /> <form-property name="age" type="java.lang.String" initial=" " /> </form-bean> </form-beans> <action-mappings> <action path="/main" name="frmPersonne" scope="session" validate="true" input="/erreurs.do" type="istia.st.struts.personne.FormulaireAction"> <forward name="reponse" path="/reponse.do" /> </action> <action path="/erreurs" parameter="/erreurs.personne.jsp" type="org.apache.struts.actions.ForwardAction"></action> <action path="/reponse" parameter="/reponse.personne.jsp" type="org.apache.struts.actions.ForwardAction"></action> <action path="/formulaire" parameter="/formulaire.personne.jsp" type="org.apache.struts.actions.ForwardAction"></action> </action-mappings> <message-resources parameter="ressources.personneressources" /> </struts-config>
Je comprends pas le message. j'ai suivi le tuto de Serge Tahé et j'utilise bien Struts 1.1 comme il fait dans le tuto.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 package istia.st.struts.personne; import javax.servlet.http.*; import org.apache.struts.action.*; public class PersonneDynaForm extends DynaActionForm { // validation public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { // gestion des erreurs ActionErrors erreurs = new ActionErrors(); // le nom doit être non vide String nom = (String)this.get("nom"); if (nom == null || nom.trim().equals("")) { erreurs.add("nomvide", new ActionError("personne.formulaire.nom.vide")); } // l'âge doit être non vide String age = (String)this.get("age"); if (age == null || age.trim().equals("")) { erreurs.add("agevide", new ActionError("personne.formulaire.age.vide")); } else { // l'âge doit être un entier positif if (!age.matches("^\\s*\\d+\\s*$")) { erreurs.add("ageincorrect", new ActionError("personne.formulaire.age.incorrect", age)); // on rend la liste des erreurs } } //if // on rend la liste d'erreurs return erreurs; } }//classe
je suis vraiment perdu
Partager