salut,
je vx créer un site avec Struts et j'ai un problème pour s'authentifier.
qlq1 a le code source de s'authentifier (vérifier le login et le mot de passe dans une base de donnée)?
si oui n'hésitez pas de me l'envoyer
et merci
salut,
je vx créer un site avec Struts et j'ai un problème pour s'authentifier.
qlq1 a le code source de s'authentifier (vérifier le login et le mot de passe dans une base de donnée)?
si oui n'hésitez pas de me l'envoyer
et merci
code pour la jsp :
et dans l'action :
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 <%@ page contentType="text/html;charset=UTF-8" language="java"%> <%@ taglib uri="/struts-tags" prefix="s"%> <html> <head> <title>Page Login</title> </head> <body> <s:form> <table cellpadding="0" cellspacing="0" width="500"> <tr> <td valign="top" width="500"> <table cellpadding="0" cellspacing="0" height="300" width="500"> <tr> <td > Titre </td> </tr> <tr> <td> <table> <tr> <td align="center"> <table summary="" class="tableFormulaire"cellpadding="0" cellspacing="0" width="300"> <tr> <td width="10"> </td> <td width="100"><label>Login <font color="red" size="1">*</font></label></td> <td width="150"><s:textfield label="login" name='username' /></td> </tr> <tr> <td width="10"> </td> <td width="100"><label for="j_spring_security_check_j_password"> Mot de passe <font color="red" size="1">*</font></label></td> <td width="161"><s:password name='password' /></td> </tr> <tr> <td colspan="2"></td> <td><s:submit value="Identification" ></s:submit></td> </tr> </table> </tr> <tr> <td colspan="5" align="center"></td> </tr> </table> </td> </tr> </table> </td> </tr> <tr> </tr> </table> </s:form> </body> </html>
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 package .....; import Model.User; public class LoginAction{ private static final long serialVersionUID = 1L; private User user; private String login; private String pwd; /** * @param pwd the pwd to set */ public void setPwd(String pwd) { this.pwd = pwd; } /** * @return the pwd */ public String getPwd() { return pwd; } /** * @param login the login to set */ public void setLogin(String login) { this.login = login; } /** * @return the login */ public String getLogin() { return login; } /** * @param user the user to set */ public void setUser(User user) { this.user = user; } /** * @return the user */ public User getUser() { return user; } public String execute() { try { user=(User)Factory.getInstance().getUserService().log(getLogin(), getPwd()); if(user!=null) return SUCCESS; else{ addActionError(getText("error.login.user")); return ERROR; } } catch (Exception e) { e.printstacktrace(); return ERROR; } } }
Note que le code utilisé concerne bien struts2
Partager