Salut
j'essaie de mettre en place un projet struts 2.
J'utilise tomcat 7.0.32, avec un jdk 1.7.0 .
Voici mon web.xml dans my WEB-INF :
Dans WEB-INF/lib j'ai les jars suivants :
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 <?xml version="1.0" encoding="UTF-8"?> <web-app id="WebApp_ID" 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>AGL</display-name> <welcome-file-list> <welcome-file>/WEB-INF/jsp/dbAccess.jsp</welcome-file> </welcome-file-list> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app>
ant-contrib-1.0b3
antlr-2.7.7
asm-3.3
asm-commons-3.3
asm-tree-3.3
commons-fileupload-1.2.2
commons-io-2.0.1
commons-lang3-3.1
dom4j-1.6.1
freemarker-2.3.19
hibernate-commons-annotations-4.0.1.Final
hibernate-core-4.1.8.Final
hibernate-jpa-2.0-api-1.0.1.Final
javassist-3.11.0.GA
jboss-logging-3.1.0.GA
jboss-transaction-api_1.1_spec-1.0.0.Final
log4j-1.2.15
mysql-connector-java-5.1.22-bin
ognl-3.0.5
struts2-core-2.3.4.1
xwork-core-2.3.4.1
Dans WEB-INF/classes j'ai log4j.xml struts.properties et struts.xml (aussi mon fichier de conf hibernate mais ce n'est pas le souci)
log4j.xml :
struts.properties:
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 <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE log4j:configuration PUBLIC "-//log4j/log4j Configuration//EN" "log4j.dtd"> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> <appender name="STDOUT" class="org.apache.log4j.ConsoleAppender" > <layout class="org.apache.log4j.PatternLayout" > <param name="ConversionPattern" value="%d %-5p %c.%M:%L - %m%n" /> </layout> </appender> <!-- specify the logging level for loggers from other libraries --> <logger name="com.opensymphony" > <level value="DEBUG" /> </logger> <logger name="org.apache.struts2" > <level value="DEBUG" /> </logger> <!-- for all other loggers log only debug and above log messages --> <root> <priority value="INFO" /> <appender-ref ref="STDOUT" /> </root> </log4j:configuration>
struts.xml :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 struts.locale = fr_CA struts.i18n.encoding = UTF-8 struts.action.extension = html,xml,json,do strutsstruts.multipart.saveDir = struts.multipart.maxSize = 52428800 struts.enable.SlashesInActionNames = true struts.mapper.alwaysSelectFullNamespace = false struts.devMode = false struts.url.includeParams = none
Et l'action qui va avec (c'est un package hot ;-) ):
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 <?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> <!-- Configuration for the default package. --> <package name="defaultAGL" extends="struts-default" namespace="/AGL"> <action name="dbAccess.*" class="com.xxx.DbAccessAction"> <result name="input">/WEB-INF/jsp/dbAccess.jsp</result> </action> </package> </struts>
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 package com.xxx; import com.opensymphony.xwork2.ActionSupport; public class DbAccessAction extends ActionSupport { private static final long serialVersionUID = 7148985984370151377L; private String messageFromAction; public String execute() { setMessageFromAction("test"); return INPUT; } public void setMessageFromAction(String messageFromAction) { this.messageFromAction = messageFromAction; } public String getMessageFromAction() { return messageFromAction; } }
Selon le namespace et le nom de l'action définit dans struts.xml je pensé avoir un résultat en accédant l'url : http://localhost:8080/AGL/dbAccess.com
malheureusement, je me prends une vieille 404 moisie....
J'ai verifié en debug, je ne passe même pas dans l'action...
j'ai franchement pas mal cherché, je pense que c'est bien con, mais si quequ'un a une idée, pliz help me!!!
Merci d'avance.
Partager