Bonjour à tous,
J'ai soucis avec Struts et maven, en fait j'ai créé un projet webapp sous maven et je voudrais utiliser struts hibernate. Mais le problème est que j'ai fait ma première page index(authentification) qui me renvoie vers une action. Lorsque je clique sur le bouton submit. Il ne trouve pas l'action, il ne fait, j'ai vérifé qu'il ne rentre même pas dans l'action.
La structure de mon projet est:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 Projet src/main/java LoginAction.java src/main/webapp index.jsp WEB-INF struts-config.xml web.xml
voici le contenu de chacun des fichiers:
index.jsp
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 <html> <body> <h2>Hello World!</h2> <body> <form action="/loginAction" method="post"> Login: <input type="text" name="login" id="login" size="10" /><br></br> Password: <input type="password" size="10" name="pwd" id="pwd"><br></br> <input type="submit" name="envoyer" value="Envoyer" id="envoyer"> </form> </body> </html>
struts-config.xml
web.xml
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 <struts-config> <form-beans> </form-beans> <action-mappings> <action path="/loginAction" scope="request" type="com.actions.LoginAction" > <forward name="succes" path="home.jsp" redirect="true" ></forward> </action> </action-mappings> </struts-config>
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<web-app> <display-name>Archetype Created Web Application</display-name> <servlet> <servlet-name>action</servlet-name> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class> <init-param> <param-name>config</param-name> <param-value>/WEB-INF/struts-config.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app>
LoginAction
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 public class LoginAction extends Action{ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { System.out.println("OKKKKKKKKKKKKKKK"); String action = request.getParameter("action"); String ch = "notFound"; if (action.equals("login")) { ch = "succes"; } return mapping.findForward(ch); } }
Partager