Bonjour,
j'ai un problem dans l'execution de struts2
dans mon fichier struts.xml j'ai l'action suivante :
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
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.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import org.jdom2.Attribute;
import org.jdom2.Document;
import org.jdom2.Element;
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 Element racine = new Element("documents");
static Document doc = new Document(racine);
public String execute() throws Exception {
Element document = new Element("document");
racine.addContent(document);
Element titre = new Element("titre");
document.addContent(titre.setText(getTitre()));
// Element id = new Element("id");
// document.setAttribute("id",for(i=0;i<10;i++){});
Element creator = new Element("creator");
document.addContent(creator.setText(getCreator()));
Element subject = new Element("subject");
document.addContent(subject.setText(getSubject()));
Element description = new Element("description");
document.addContent(description.setText(getDescription()));
Element date = new Element("date");
document.addContent(date.setText(getDate()));
XMLOutputter sortie = new XMLOutputter(Format.getPrettyFormat());
// sortie.output(document, System.out);
sortie.output(doc, new FileOutputStream("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
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>
<title>Ajout Document</title>
<meta name="DC.Title" 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"
style="width:50%;margin:auto;background-color:green;padding-bottom:15px;">
<h2 style="text-align: center; color: white; background-color: green;">
<h2>Formulaire d'ajout de Document</h2>
<p style="text-align: center;"><s:textfield type="text"
name="titre" label="Titre" size="20"></s:textfield>
<p style="text-align: center;"><s:textfield type="text"
name="creator" label="Createur" size="20"></s:textfield>
<p style="text-align: center;"><s:textfield type="text"
name="subject" label="Sujet" size="20"></s:textfield>
<p style="text-align: center;"><s:textfield type="text"
name="description" label="Description" size="20"></s:textfield>
<p style="text-align: center;"><s:textfield type="text" name="date"
label="Date d'ajout" size="20"></s:textfield> <%-- <p style="text-align:center;"> <s:file name="upload" label="File" /> --%>
<%-- <s:file name="fileUpload" label="Select a File to upload" size="40" /> --%>
<p style="text-align: center; width: 50%; margin: auto;"><s:reset
type="reset" value="Annuler"></s:reset>
<p style="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
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">
<title>Insert title here</title>
</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
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 disponible.
--------------------------------------------------------------------------------
Apache Tomcat/6.0.35 |
d'aprè ce que j'ai compris , il ne reconnait pas le result success de cette action
je sais pa pourquoi , alors que dans l'actionbean j'ai mis
aidez moi SVP
Partager