Bonjour à tous.
Je suis en cours de développement d'un site web dynamique. J'ai connu un problème dans la vérification des donnés insérer par l'utilisateur "login et mot de passe" et les vérifier par celles dans la base de donnée de ma table personnee.
Voila le code :
ici la vérification ce fait seulement sur les valeurs login = "xyz" w mt pass="xyz" mais j aime avoir comment vérifier les donnés déjà dans les colonnes de ma table.
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 package com.struts.controlleur; import org.hibernate.*; import com.ana.Personnee; import com.util.HibernateUtil; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.Action; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import com.struts.data.loginForm; import com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable; public final class loginAction extends Action { public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String resultat = null; String idUser = ((loginForm) form).getIdUser(); String passwordPersonne = ((loginForm) form).getPasswordPersonne(); if (idUser.equals("xyz") && passwordPersonne.equals("xyz")) { resultat = "succes"; } else { resultat = "echec"; } return mapping.findForward(resultat); } }
voila aussi le code de personne.java car j utilise struts :
et voila le code de loginform
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
109
110
111
112 package com.ana; // Generated 18 mars 2012 14:55:00 by Hibernate Tools 3.2.0.beta8 /** * Personnee generated by hbm2java */ public class Personnee implements java.io.Serializable { // Fields private String nomPersonne; private String prenomPersonne; private String villePersonne; private String paysPersonne; private String telephonePersonne; private String emailPersonne; private String idUser; private String passwordPersonne; // Constructors /** default constructor */ public Personnee() { } /** minimal constructor */ public Personnee(String nomPersonne) { this.nomPersonne = nomPersonne; } /** full constructor */ public Personnee(String nomPersonne, String prenomPersonne, String villePersonne, String paysPersonne, String telephonePersonne, String emailPersonne, String idUser, String passwordPersonne) { this.nomPersonne = nomPersonne; this.prenomPersonne = prenomPersonne; this.villePersonne = villePersonne; this.paysPersonne = paysPersonne; this.telephonePersonne = telephonePersonne; this.emailPersonne = emailPersonne; this.idUser = idUser; this.passwordPersonne = passwordPersonne; } // Property accessors public String getNomPersonne() { return this.nomPersonne; } public void setNomPersonne(String nomPersonne) { this.nomPersonne = nomPersonne; } public String getPrenomPersonne() { return this.prenomPersonne; } public void setPrenomPersonne(String prenomPersonne) { this.prenomPersonne = prenomPersonne; } public String getVillePersonne() { return this.villePersonne; } public void setVillePersonne(String villePersonne) { this.villePersonne = villePersonne; } public String getPaysPersonne() { return this.paysPersonne; } public void setPaysPersonne(String paysPersonne) { this.paysPersonne = paysPersonne; } public String getTelephonePersonne() { return this.telephonePersonne; } public void setTelephonePersonne(String telephonePersonne) { this.telephonePersonne = telephonePersonne; } public String getEmailPersonne() { return this.emailPersonne; } public void setEmailPersonne(String emailPersonne) { this.emailPersonne = emailPersonne; } public String getIdUser() { return this.idUser; } public void setIdUser(String idUser) { this.idUser = idUser; } public String getPasswordPersonne() { return this.passwordPersonne; } public void setPasswordPersonne(String passwordPersonne) { this.passwordPersonne = passwordPersonne; } }
Et merci d'avance
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 package com.struts.data; import org.apache.struts.action.*; import javax.servlet.http.HttpServletRequest; public class loginForm extends ActionForm { /** * */ private static final long serialVersionUID = 1L; private String idUser; private String passwordPersonne; public String getIdUser() { return this.idUser; } public void setIdUser(String idUser) { this.idUser = idUser; } public String getPasswordPersonne() { return this.passwordPersonne; } public void setPasswordPersonne(String passwordPersonne) { this.passwordPersonne = passwordPersonne; } public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); return errors; } public void reset(ActionMapping mapping, HttpServletRequest request) { this.idUser = null; this.passwordPersonne = null; } }![]()
Partager