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 dans l'exécution de Struts 2


Sujet :

Struts 2 Java

  1. #1
    Membre très actif
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Mai 2012
    Messages
    169
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2012
    Messages : 169
    Par défaut Problème dans l'exécution de Struts 2
    Bonjour,

    j'ai un probm dans l'execution de struts2

    dans mon fichier struts.xml j'ai l'action suivante :

    Code : Séctionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    <action name="DocumentAction" class="beanAction.DocumentAction">
    			<result name="document">index.jsp</result>
                <result name="success">./jsp/SuccessDocument.jsp</result>
    		</action>

    et mon actionbean

    Code : Séctionner 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
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
     
    package beanAction;
     
    import java.io.Fi;
    import java.io.FiOutputStream;
    import java.io.IOException;
    import java.util.Colction;
    import java.util.Iterator;
    import java.util.List;
    import org.jdom2.Attribute;
    import org.jdom2.Document;
    import org.jdom2.Ement;
    import org.jdom2.JDOMException;
    import org.jdom2.input.SAXBuilder;
    import org.jdom2.output.Format;
    import org.jdom2.output.XMLOutputter;
     
    import com.opensymphony.xwork2.ActionSupport;
     
    public class DocumentAction extends ActionSupport {
     
    	private static final long serialVersionUID = 1L;
     
    	private String titre;
    	private String creator;
    	private String subject;
    	private String description;
    	private String date;
        private int id;
        private int i=10;
     
     
     
     
    	static Ement racine = new Ement("documents");
    	static Document doc = new Document(racine);
     
    	public String execute() throws Exception {
    		Ement document = new Ement("document");
    		racine.addContent(document);
     
    		Ement titre = new Ement("titre");
    		document.addContent(titre.setText(getTitre()));
     
    //			Ement id = new Ement("id");
    //			document.setAttribute("id",for(i=0;i<10;i++){});	
     
     
     
    		Ement creator = new Ement("creator");
    		document.addContent(creator.setText(getCreator()));
     
    		Ement subject = new Ement("subject");
    		document.addContent(subject.setText(getSubject()));
     
    		Ement description = new Ement("description");
    		document.addContent(description.setText(getDescription()));
     
    		Ement date = new Ement("date");
    		document.addContent(date.setText(getDate()));
     
    		XMLOutputter sortie = new XMLOutputter(Format.getPrettyFormat());
    		// sortie.output(document, System.out);
    		sortie.output(doc, new FiOutputStream("C:/Documents and Settings/Administrateur/Mes documents/workspace/GED-1.1/ressources/documents.xml"));
     
     
     
     
    		return SUCCESS;}
     
    	// getters and setters
     
    	public int getId() {
    		return id;
    	}
     
    	public void setId(int id) {
    		this.id = id;
    	}
     
    	public String getTitre() {
    		return titre;
    	}
     
    	public void setTitre(String titre) {
    		this.titre = titre;
    	}
     
    	public String getCreator() {
    		return creator;
    	}
     
    	public void setCreator(String creator) {
    		this.creator = creator;
    	}
     
    	public String getSubject() {
    		return subject;
    	}
     
    	public void setSubject(String subject) {
    		this.subject = subject;
    	}
     
    	public String getDescription() {
    		return description;
    	}
     
    	public void setDescription(String description) {
    		this.description = description;
    	}
    	public String getDate() {
    		return date;
    	}
     
    	public void setDate(String date) {
    		this.date = date;
    	}
    }

    et deux page jsp , un formulaire de saisi et une page qui affiche que l'ajout du document a été reussi , cette dernière ne s'affiche pas


    formulaire

    Code : Séctionner 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
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    	pageEncoding="ISO-8859-1"%>
    <%@taglib prefix="s" uri="/struts-tags"%>
    <html>
    <head>
    <tit>Ajout Document</tit>
    <meta name="DC.Tit" xml:lang="EN" content="Dublin Core " />
    <meta name="DC.Creator" content="Alan Kelsey" />
    <meta name="DC.Subject" xml:lang="EN" content="Dublin Core Meta Tags" />
    <meta name="DC.Description" xml:lang="EN" content="documents" />
    <meta name="DC.Date" xml:lang="EN" content="date" />
     
    </head>
    <body>
    <center><s:form action="DocumentAction" method="post"
    	sty="width:50%;margin:auto;background-color:green;padding-bottom:15px;">
    	<h2 sty="text-align: center; color: white; background-color: green;">
    	<h2>Formulaire d'ajout de Document</h2>
     
     
    	<p sty="text-align: center;"><s:textfield type="text"
    		name="titre" label="Titre" size="20"></s:textfield>
    	<p sty="text-align: center;"><s:textfield type="text"
    		name="creator" label="Createur" size="20"></s:textfield>
    	<p sty="text-align: center;"><s:textfield type="text"
    		name="subject" label="Sujet" size="20"></s:textfield>
    	<p sty="text-align: center;"><s:textfield type="text"
    		name="description" label="Description" size="20"></s:textfield>
    	<p sty="text-align: center;"><s:textfield type="text" name="date"
    		label="Date d'ajout" size="20"></s:textfield> <%-- 		 <p sty="text-align:center;">	<s:fi name="upload" label="Fi" />  --%>
    	<%-- 	<s:fi name="fiUpload" label="Sect a Fi to upload" size="40" />  --%>
    	<p sty="text-align: center; width: 50%; margin: auto;"><s:reset
    		type="reset" value="Annur"></s:reset>
    	<p sty="text-align: center; width: 50%; margin: auto;"><s:submit
    		type="submit" value="Ajouter un document"></s:submit>
    </s:form></center>
    </body>
    </html>

    page d'affichage
    Code : Séctionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
     
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
        pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <tit>Insert tit here</tit>
    </head>
    <body>
    <center>Document Ajouté avec success</center>
    </body>
    </html>
    l'ajout il passe bien mais la page d'affichage ne demarre pas
    eclipse me donne cette erreur

    Code : Séctionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
     
    Etat HTTP 404 - No result defined for action beanAction.DocumentAction and result success
     
    --------------------------------------------------------------------------------
     
    type Rapport d'état
     
    message No result defined for action beanAction.DocumentAction and result success
     
    description La ressource demandée (No result defined for action beanAction.DocumentAction and result success) n'est pas disponib.
     
     
    --------------------------------------------------------------------------------
     
    Apache Tomcat/6.0.35
    d'aprè ce que j'ai compris , il ne reconnait pas result success de cette action

    je sais pa pourquoi , alors que dans l'actionbean j'ai mis

    aidez moi SVP

  2. #2
    Membre très actif Avatar de tunizar
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    573
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2007
    Messages : 573
    Par défaut
    Salut,
    il y a ça
    http://struts.apache.org/2.2.3/docs/...alidation.html


    If you don't have this, you'll get a: "No result defined for action xxx.xxx.tutorial.HellowWorld and result input" error
    Citation Envoyé par fruwen7 Voir  message
    Bonjour,

    j'ai un probm dans l'execution de struts2

    dans mon fichier struts.xml j'ai l'action suivante :

    Code : Séctionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    <action name="DocumentAction" class="beanAction.DocumentAction">
    			<result name="document">index.jsp</result>
                <result name="success">./jsp/SuccessDocument.jsp</result>
    		</action>

    et mon actionbean

    Code : Séctionner 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
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
     
    package beanAction;
     
    import java.io.Fi;
    import java.io.FiOutputStream;
    import java.io.IOException;
    import java.util.Colction;
    import java.util.Iterator;
    import java.util.List;
    import org.jdom2.Attribute;
    import org.jdom2.Document;
    import org.jdom2.Ement;
    import org.jdom2.JDOMException;
    import org.jdom2.input.SAXBuilder;
    import org.jdom2.output.Format;
    import org.jdom2.output.XMLOutputter;
     
    import com.opensymphony.xwork2.ActionSupport;
     
    public class DocumentAction extends ActionSupport {
     
    	private static final long serialVersionUID = 1L;
     
    	private String titre;
    	private String creator;
    	private String subject;
    	private String description;
    	private String date;
        private int id;
        private int i=10;
     
     
     
     
    	static Ement racine = new Ement("documents");
    	static Document doc = new Document(racine);
     
    	public String execute() throws Exception {
    		Ement document = new Ement("document");
    		racine.addContent(document);
     
    		Ement titre = new Ement("titre");
    		document.addContent(titre.setText(getTitre()));
     
    //			Ement id = new Ement("id");
    //			document.setAttribute("id",for(i=0;i<10;i++){});	
     
     
     
    		Ement creator = new Ement("creator");
    		document.addContent(creator.setText(getCreator()));
     
    		Ement subject = new Ement("subject");
    		document.addContent(subject.setText(getSubject()));
     
    		Ement description = new Ement("description");
    		document.addContent(description.setText(getDescription()));
     
    		Ement date = new Ement("date");
    		document.addContent(date.setText(getDate()));
     
    		XMLOutputter sortie = new XMLOutputter(Format.getPrettyFormat());
    		// sortie.output(document, System.out);
    		sortie.output(doc, new FiOutputStream("C:/Documents and Settings/Administrateur/Mes documents/workspace/GED-1.1/ressources/documents.xml"));
     
     
     
     
    		return SUCCESS;}
     
    	// getters and setters
     
    	public int getId() {
    		return id;
    	}
     
    	public void setId(int id) {
    		this.id = id;
    	}
     
    	public String getTitre() {
    		return titre;
    	}
     
    	public void setTitre(String titre) {
    		this.titre = titre;
    	}
     
    	public String getCreator() {
    		return creator;
    	}
     
    	public void setCreator(String creator) {
    		this.creator = creator;
    	}
     
    	public String getSubject() {
    		return subject;
    	}
     
    	public void setSubject(String subject) {
    		this.subject = subject;
    	}
     
    	public String getDescription() {
    		return description;
    	}
     
    	public void setDescription(String description) {
    		this.description = description;
    	}
    	public String getDate() {
    		return date;
    	}
     
    	public void setDate(String date) {
    		this.date = date;
    	}
    }

    et deux page jsp , un formulaire de saisi et une page qui affiche que l'ajout du document a été reussi , cette dernière ne s'affiche pas


    formulaire

    Code : Séctionner 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
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    	pageEncoding="ISO-8859-1"%>
    <%@taglib prefix="s" uri="/struts-tags"%>
    <html>
    <head>
    <tit>Ajout Document</tit>
    <meta name="DC.Tit" xml:lang="EN" content="Dublin Core " />
    <meta name="DC.Creator" content="Alan Kelsey" />
    <meta name="DC.Subject" xml:lang="EN" content="Dublin Core Meta Tags" />
    <meta name="DC.Description" xml:lang="EN" content="documents" />
    <meta name="DC.Date" xml:lang="EN" content="date" />
     
    </head>
    <body>
    <center><s:form action="DocumentAction" method="post"
    	sty="width:50%;margin:auto;background-color:green;padding-bottom:15px;">
    	<h2 sty="text-align: center; color: white; background-color: green;">
    	<h2>Formulaire d'ajout de Document</h2>
     
     
    	<p sty="text-align: center;"><s:textfield type="text"
    		name="titre" label="Titre" size="20"></s:textfield>
    	<p sty="text-align: center;"><s:textfield type="text"
    		name="creator" label="Createur" size="20"></s:textfield>
    	<p sty="text-align: center;"><s:textfield type="text"
    		name="subject" label="Sujet" size="20"></s:textfield>
    	<p sty="text-align: center;"><s:textfield type="text"
    		name="description" label="Description" size="20"></s:textfield>
    	<p sty="text-align: center;"><s:textfield type="text" name="date"
    		label="Date d'ajout" size="20"></s:textfield> <%-- 		 <p sty="text-align:center;">	<s:fi name="upload" label="Fi" />  --%>
    	<%-- 	<s:fi name="fiUpload" label="Sect a Fi to upload" size="40" />  --%>
    	<p sty="text-align: center; width: 50%; margin: auto;"><s:reset
    		type="reset" value="Annur"></s:reset>
    	<p sty="text-align: center; width: 50%; margin: auto;"><s:submit
    		type="submit" value="Ajouter un document"></s:submit>
    </s:form></center>
    </body>
    </html>

    page d'affichage
    Code : Séctionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
     
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
        pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <tit>Insert tit here</tit>
    </head>
    <body>
    <center>Document Ajouté avec success</center>
    </body>
    </html>
    l'ajout il passe bien mais la page d'affichage ne demarre pas
    eclipse me donne cette erreur

    Code : Séctionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
     
    Etat HTTP 404 - No result defined for action beanAction.DocumentAction and result success
     
    --------------------------------------------------------------------------------
     
    type Rapport d'état
     
    message No result defined for action beanAction.DocumentAction and result success
     
    description La ressource demandée (No result defined for action beanAction.DocumentAction and result success) n'est pas disponib.
     
     
    --------------------------------------------------------------------------------
     
    Apache Tomcat/6.0.35
    d'aprè ce que j'ai compris , il ne reconnait pas result success de cette action

    je sais pa pourquoi , alors que dans l'actionbean j'ai mis

    aidez moi SVP

  3. #3
    Membre très actif
    Inscrit en
    Novembre 2004
    Messages
    234
    Détails du profil
    Informations forums :
    Inscription : Novembre 2004
    Messages : 234
    Par défaut
    dans ton action c 'est return "success";
    et dans struts.xml
    <result name="success">./jsp/SuccessDocument.jsp</result>
    </action>

    il faut respecter s majuscus il me semb et succes

Discussions similaires

  1. Réponses: 0
    Dernier message: 01/01/2010, 16h30
  2. Réponses: 4
    Dernier message: 14/11/2009, 14h52
  3. Problème dans l'exécution d'une requete !
    Par zouzou_18 dans le forum VB.NET
    Réponses: 4
    Dernier message: 07/08/2009, 16h30
  4. Problème dans l'exécution du start.bat sous jbpm
    Par Simply Smart dans le forum Wildfly/JBoss
    Réponses: 1
    Dernier message: 19/02/2008, 14h31

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