IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Struts 2 Java Discussion :

Problème de définition d'action


Sujet :

Struts 2 Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Juillet 2007
    Messages
    50
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2007
    Messages : 50
    Par défaut Problème de définition d'action
    Bonjour à tous,

    Bon voila, je commence tout juste avec Struts2. J'ai récupéré l'archetype d'un projet Struts2 avec Maven qui m'a créé un beau projet.
    J'ai définis toutes mes dépendances comme il se doit. Puis j'ai essayé d'intégrer Spring en suivant ce tuto : http://struts.apache.org/2.0.8/docs/...-jpa-ajax.html

    Malheureusement, mes actions Struts sont introuvables...

    Je vous joins mon struts.xml :

    Code xml : 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
    <?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.objectFactory" value="spring" />
        <constant name="struts.devMode" value="true" />
     
        <package name="person" extends="struts-default">
     
            <action name="list" class="personAction" method="execute" >
                <result>jsp/list.jsp</result>
                <result name="input">jsp/list.jsp</result>
            </action>
     
            <action name="remove" class="personAction" method="remove">
                <result>jsp/list.jsp</result>
                <result name="input">jsp/list.jsp</result>
            </action>
     
            <action name="save" class="personAction" method="save">
                <result>jsp/list.jsp</result>
                <result name="input">jsp/list.jsp</result>
            </action>
        </package>
     
    </struts>

    et mon applicationContext.xml :
    Code xml : 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
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:aop="http://www.springframework.org/schema/aop"
        xmlns:tx="http://www.springframework.org/schema/tx"
        xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
     
        <bean
            class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
     
        <bean id="personService" class="com.service.PersonServiceImpl" />
     
        <bean id="entityManagerFactory"
            class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
            <property name="dataSource" ref="dataSource" />
            <property name="jpaVendorAdapter">
                <bean
                    class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                    <property name="database" value="" />
                    <property name="showSql" value="true" />
                </bean>
            </property>
        </bean>
     
        <bean id="dataSource"
            class="org.springframework.jdbc.datasource.DriverManagerDataSource">
            <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
            <property name="url" value="jdbc:oracle:thin:@localhost:1521:xe" />
            <property name="username" value="" />
            <property name="password" value="" />
        </bean>
     
        <bean id="transactionManager"
            class="org.springframework.orm.jpa.JpaTransactionManager">
            <property name="entityManagerFactory" ref="entityManagerFactory" />
        </bean>
     
        <tx:annotation-driven transaction-manager="transactionManager" />
     
        <bean id="personAction" scope="prototype"
            class="com.action.PersonAction">
            <constructor-arg ref="personService" />
        </bean>
    </beans>

    Lorsque je vais sur mon index.jsp, il me sort une 404 en me disant qu'il n'existe pas d'action pour le namespace.

    Ca fait deux jours que je suis sur ce problème et ça commence légèrement à me saouler... J'espère que vous pourrez me dépanner.

    Merci d'avance.

  2. #2
    Membre confirmé
    Inscrit en
    Janvier 2006
    Messages
    79
    Détails du profil
    Informations forums :
    Inscription : Janvier 2006
    Messages : 79
    Par défaut
    Salut,

    J'ai le même projet que toi un peu plus avancé.
    Mon struts.xml ressemble à ça :
    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>
    	<package name="myPackage" extends="struts-default">
     
    		<action name="index" class="tutorial.IndexAction">
    			<result>/jsp/index.jsp</result>
    		</action>
    ... 	</package>
    </struts>
    C'est le strict minimum pas besoin d'autres balises superflu.
    Pour le applicationContext.xml c'est la meme :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC
    	"-//SPRING//DTD BEAN//EN"
    	"http://www.springframework.org/dtd/spring-beans.dtd">
     
    <beans>
    	<!-- Example of SAF2 action instantiated by Spring -->
        <bean id="helloWorldAction" 	class="tutorial.HelloWorldAction" 				singleton="false" />
    ...
    </beans>
    As tu pensé à modifier ton web.xml, peux tu nous le montrer ?
    As tu parametrer un fichier struts.properties convenablement ?

  3. #3
    Membre averti
    Profil pro
    Inscrit en
    Juillet 2007
    Messages
    50
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2007
    Messages : 50
    Par défaut
    En fait, j'ai suivi le tuto tout simplement, donc j'ai laissé plus ou moins par défaut, hormis les noms de package que j'ai essayé de réadapter.

    Donc voici mon web.xml :

    Code xml : 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
     
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app id="person" 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>person</display-name>
     
        <context-param>
    		<param-name>contextConfigLocation</param-name>
    		<param-value>classpath*:applicationContext*.xml</param-value>
    	</context-param>
     
        <filter>
            <filter-name>struts2</filter-name>
            <filter-class>
                org.apache.struts2.dispatcher.FilterDispatcher
            </filter-class>
            <init-param>
    			<param-name>actionPackages</param-name>
    			<param-value>com.action</param-value>
    		</init-param>
     
        </filter>
     
        <filter-mapping>
            <filter-name>struts2</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
     
     
        <welcome-file-list>
            <welcome-file>index.jsp</welcome-file>
        </welcome-file-list>
     
        <listener>
            <listener-class>
                org.springframework.web.context.ContextLoaderListener
            </listener-class>
        </listener>
    </web-app>


    et mon 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
    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
     
     
     
    # struts.configuration=org.apache.struts2.config.DefaultConfiguration
     
    # struts.locale=en_US
    struts.i18n.encoding=UTF-8
     
    struts.objectFactory = spring
     
    struts.objectFactory.spring.autoWire = name
     
    struts.objectFactory.spring.useClassCache = true
     
    #struts.objectTypeDeterminer = tiger
    #struts.objectTypeDeterminer = notiger
     
    # struts.multipart.parser=cos
    # struts.multipart.parser=pell
    struts.multipart.parser=jakarta
    # uses javax.servlet.context.tempdir by default
    struts.multipart.saveDir=
    struts.multipart.maxSize=2097152
     
    # struts.custom.properties=application,com/webwork/extension/custom
     
    struts.mapper.class=org.apache.struts2.dispatcher.mapper.DefaultActionMapper
     
    struts.action.extension=action
     
    struts.serve.static=true
     
    struts.serve.static.browserCache=true
     
    struts.tag.altSyntax=true
     
    struts.devMode = false
     
    struts.i18n.reload=false
     
    struts.ui.theme=xhtml
    struts.ui.templateDir=template
    #sets the default template type. Either ftl, vm, or jsp
    struts.ui.templateSuffix=ftl
     
    struts.configuration.xml.reload=false
     
    # struts.velocity.configfile = velocity.properties
     
    # struts.velocity.contexts =
     
    struts.url.http.port = 80
    struts.url.https.port = 443
     
    # struts.custom.i18n.resources=testmessages,testmessages2
    struts.custom.i18n.resources=globalmessages
     
    struts.dispatcher.parametersWorkaround = false
     
    #struts.freemarker.manager.classname=org.apache.struts2.views.freemarker.FreemarkerManager
     
    struts.freemarker.wrapper.altMap=true
     
    struts.xslt.nocache=false

  4. #4
    Membre confirmé
    Inscrit en
    Janvier 2006
    Messages
    79
    Détails du profil
    Informations forums :
    Inscription : Janvier 2006
    Messages : 79
    Par défaut
    As tu regarder du coté de tomcat, erreur 404 c'est lorsque que l'on ne trouve pas une ressource.
    rassure moi ton .war est bien dans ton "Tomcat V5.5.9\webapps" ?

  5. #5
    Membre averti
    Profil pro
    Inscrit en
    Juillet 2007
    Messages
    50
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2007
    Messages : 50
    Par défaut
    Oui là n'est pas le problème, il trouve bien ma page Web. C'est seulement les actions qu'il ne trouve pas. Je visualise bien ma page avec tout ce qu'il y a dessus, mais dès que j'effectue une action Struts, il me sort :
    "Error loading '/ProjetWeb/list.action' (404 There is no Action mapped for namespace / and action name list.)"

Discussions similaires

  1. [Système] Problème de définition des variables
    Par SLAM JACK dans le forum Langage
    Réponses: 6
    Dernier message: 29/03/2006, 19h53
  2. [Configuration] Problème sur définition de constante
    Par Yobs dans le forum EDI, CMS, Outils, Scripts et API
    Réponses: 4
    Dernier message: 24/03/2006, 11h40
  3. Réponses: 1
    Dernier message: 21/12/2005, 19h08
  4. Réponses: 2
    Dernier message: 17/08/2005, 11h20
  5. Réponses: 22
    Dernier message: 05/07/2005, 00h04

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo