Salut ,
j'ai l'exception suivante, elle est lance quand je veux enregistrer ou modifier des champs de ma BD
La classe ValidatePersonne
Code : Sélectionner tout - Visualiser dans une fenêtre à part Validator class istia.st.springmvc.personnes.web.ValidatePersonne does not support class istia.st.springmvc.personnes.hibernate.Personnes
et la classe Personnes est
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
37 package istia.st.springmvc.personnes.web; import istia.st.springmvc.personnes.entites.Personne; import org.springframework.validation.Errors; public class ValidatePersonne implements org.springframework.validation.Validator { public boolean supports(Class classe) { return classe.isAssignableFrom(Personne.class); } public void validate(Object obj, Errors erreurs) { // on récupère la personne postée Personne personne = (Personne) obj; // on vérifie le prénom String prénom = personne.getPrenom(); if (prénom==null || prénom.trim().length() == 0) { erreurs.rejectValue("prenom", "personne.prenom.necessaire", "Le prénom est nécessaire !"); } // on vérifie le nom String nom = personne.getNom(); if (nom==null || nom.trim().length() == 0) { erreurs.rejectValue("nom", "personne.nom.necessaire", "Le nom est nécessaire !"); } // on vérifie le nombre d'enfants int nbEnfants = personne.getNbEnfants(); if (nbEnfants < 0) { erreurs.rejectValue("nbEnfants", "personne.nbEnfants.invalide", "Donnée incorrecte !"); } } }
merci de votre aide
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108 package istia.st.springmvc.personnes.hibernate; import java.io.Serializable; import java.util.Date; import org.apache.commons.lang.builder.ToStringBuilder; /** @author Hibernate CodeGenerator */ public class Personnes implements Serializable { /** identifier field */ private Integer Id; /** nullable persistent field */ private Integer Version; /** nullable persistent field */ private Date Datenaissance; /** nullable persistent field */ private String Nom; /** nullable persistent field */ private String Prenom; /** nullable persistent field */ private Integer Nbenfants; /** nullable persistent field */ private Integer Marie; /** full constructor */ public Personnes(Integer Version, Date Datenaissance, String Nom, String Prenom, Integer Nbenfants, Integer Marie) { this.Version = Version; this.Datenaissance = Datenaissance; this.Nom = Nom; this.Prenom = Prenom; this.Nbenfants = Nbenfants; this.Marie = Marie; } /** default constructor */ public Personnes() { } public Integer getId() { return this.Id; } public void setId(Integer Id) { this.Id = Id; } public Integer getVersion() { return this.Version; } public void setVersion(Integer Version) { this.Version = Version; } public Date getDatenaissance() { return this.Datenaissance; } public void setDatenaissance(Date Datenaissance) { this.Datenaissance = Datenaissance; } public String getNom() { return this.Nom; } public void setNom(String Nom) { this.Nom = Nom; } public String getPrenom() { return this.Prenom; } public void setPrenom(String Prenom) { this.Prenom = Prenom; } public Integer getNbenfants() { return this.Nbenfants; } public void setNbenfants(Integer Nbenfants) { this.Nbenfants = Nbenfants; } public Integer getMarie() { return this.Marie; } public void setMarie(Integer Marie) { this.Marie = Marie; } public String toString() { return new ToStringBuilder(this) .append("Id", getId()) .toString(); } }
Partager