Bonjour j'essaye de faire fonctionner une application struts, mais j'ai ce message d'erreur quand je tape l'URL:
Code : Sélectionner tout - Visualiser dans une fenêtre à part http://localhost:8080/exemple02/Ajouter_Client.action
Voici l'arborescence de mon application sous Eclipse:Etat HTTP 404 -
--------------------------------------------------------------------------------
type Rapport d'état
message
description La ressource demandée () n'est pas disponible.
exemple02
/JRE System Library [jre6]
/Referenced Libraries
/WEB-INF/src/exemple02/Client.java
/WEB-INF/src/struts.xml
/work
/bin
/css/styles.css
/jsp/AfficherClient.jsp
/jsp/AjouterClient.jsp
/src
/WEB-INF/lib
/WEB-INF/web.xml
Client.java
struts.xml
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 package exemple02; import java.io.Serializable; @SuppressWarnings("serial") public class Client implements Serializable { private String identifiant; private String motdepasse; public String getIdentifiant() { return identifiant; } public void setIdentifiant(String identifiant) { this.identifiant = identifiant; } public String getMotdepasse() { return motdepasse; } public void setMotdepasse(String motdepasse) { this.motdepasse = motdepasse; } public String execute() { System.out.println("Dans la méthode de<+>l'action"); return "success"; } }
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 <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <constant name="struts.enable.DynamicMethodInvocation" value="false" /> <constant name="struts.devMode" value="true" /> <package name="exemple02" namespace="/" extends="struts-default"> <default-action-ref name="Ajouter_Client" /> <action name="Ajouter_Client"> <result>/jsp/AjouterClient.jsp</result> </action> <action name="ValiderAjouter_Client" class="exemple02.Client"> <result>/jsp/AfficherClient.jsp</result> </action> </package> </struts>
styles.css
AfficherClient.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
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 BODY { font: 9 Times New Roman, Times, serif; color : #000000; background : #0000FF () fixes ; SCROLLBAR-FACE-COLOR: #FFFFFF; SCROLLBAR-HIGHLIGHT-COLOR: #808080; SCROLLBAR-SHADOW-COLOR: #FFFFFF; SCROLLBAR-3DLIGHT-COLOR: #CCCCCC; SCROLLBAR-ARROW-COLOR: #808080; SCROLLBAR-TRACK-COLOR: #FFFFFF; SCROLLBAR-DARKSHADOW-COLOR: #FFFFFF;} P { font-size : 12; font-family : Arial, Helvetica, sans-serif; color : #FFFF00; text-align : left; margin : 2; } A { color:#CC0000; font: 4486a9 Georgia, Times New Roman, Times, serif ; text-decoration:underline; } A:hover { color:#000000; font: bold 9 Times New Roman, Times, serif ; text-decoration:none; } } A:visited { color:#FF0000; font: 9 Times New Roman, Times, serif ; text-decoration:underline; } TEXTAREA { FONT-SIZE: 9; FONT-FAMILY: Times New Roman, Times, serif; BACKGROUND-COLOR:#CCCCCC; border-style: solid; } INPUT { FONT-SIZE: 9; FONT-FAMILY: Times New Roman, Times, serif; background-color: #FFFFFF; border-style:solid} SELECT { FONT-SIZE: 9; FONT-FAMILY: Times New Roman, Times, serif; BACKGROUND-COLOR: #33CC00; border-style: solid;
AjouterClient.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
15
16 <%@ taglib prefix="s" uri="/struts-tags" %> <html> <head> <title>Afficher le client</title> <style type="text/css">@import url(css/styles.css);</style> </head> <body> <div id="enveloppe"> <p> <h4>Informations sur le client:</h4> Identifiant : <s:property value="identifiant"/><br/> Mot de passe : <s:property value="motdepasse"/><br/> </p> </div> </body> </html>
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
14
15
16
17
18
19
20
21
22
23
24
25
26 <html> <head> <title>Ajouter un client </title> <style type="text/css">@import url(css/styles.css);</style> </head> <body> <div id="enveloppe"> <h3>Ajouter un client</h3> <form method="post" action="ValiderAjouter_Client.action"> <table> <tr> <td>Identifiant:</td> <td><input type="text" name="identifiant"/></td> </tr> <tr> <td>Mot de passe:</td> <td><input type="text" name="motdepasse"/></td> </tr> <tr> <td colspan="2" align="center"><input type="submit" value="Ajouter le client"/></td> </tr> </table> </form> </div> </body> </html>
Voilà, j'ai donné tous les sources que j'avais, peut-être avez-vous une idée?
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 <?xml version="1.0" encoding="UTF-8"?> <web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <display-name>Struts Blank</display-name> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app>
Merci d'avance.
Mumu27!
Partager