Bonjour tout le monde.
J'ai cette erreur qui vient lorsque je déploye le serveur et pourtant j'ai l'impression d'avoir bien codé mon fichier struts-config, mon formbean ainsi que mon actionbean.
Voici mon fichier struts-config:
voici mon Beanform:
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> <data-sources/> <form-beans type="org.apache.struts.action.ActionFormBean"> <form-bean name="formulaire" type="servlet.Logoform"/> </form-beans> <global-exceptions/> <global-forwards/> <action-mappings type="org.apache.struts.action.ActionMapping"> <action path="/dologin" parameter="" input="/index.jsp" scope="request" name="formulaire" type="servlet.Logonaction"> <forward name="succes" path="/index.jsp" redirect="false" /> <forward name="echec" path="/login.jsp" redirect="false"/> </action> </action-mappings> <controller/> <message-resources null="false" parameter="controle_fr"/> </struts-config>
Voici mon Beanaction:
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 package servlet; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.*; /** * Servlet implementation class for Servlet: Logonform * */ public class Logonform extends ActionForm{ /* (non-Java-doc) * @see javax.servlet.http.HttpServlet#HttpServlet() */ private String username; private String password; private String test; public void setUsername(String newusername) { this.username=newusername; } public String getUsername() { return this.username; } public void setPassword(String newpassword) { this.password=newpassword; } public String getPassword() { return this.password; } public void setTest(String newTest) { this.test=newTest; } public String getTest() { return this.test; } public ActionErrors validate(ActionMapping mapping,HttpServletRequest request) { ActionErrors errors=new ActionErrors(); if (this.getUsername().length()<1) { errors.add("Username", new ActionError("error.index.username")); } if(this.getPassword().length()<3) { errors.add("Password",new ActionError("error.index.password")); } if (this.getTest().length()<3) { errors.add("Test", new ActionError("error.index.test")); } return errors; } public void reset (ActionMapping mapping,HttpServletRequest request) { this.username=null; this.password=null; this.test=null; } }
Je vous remercie 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 package servlet; import java.io.IOException; import java.util.Vector; import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.struts.action.*; import modele.*; import classe.Logon; /** * Servlet implementation class for Servlet: LogonAction * */ public class Logonaction extends Action { /* (non-Java-doc) * @see javax.servlet.http.HttpServlet#HttpServlet() */ public ActionForward execute (ActionMapping mapping,ActionForm form, HttpServletRequest Request, HttpServletResponse response) { String username=((Logonform)form).getUsername(); String password=((Logonform)form).getPassword(); String result=null; if(Logon.checkUser(username, password)) { Userlist userList= new Userlist(); Vector <User> users = userList.getUsers() ; Request.setAttribute("users",users); result="succes"; } else { result="echec"; } return mapping.findForward(result); } }
Partager