Probleme struts sous eclipse 3.3.3 europa

abdo77 Messages postés 3 Date d'inscription mercredi 25 mai 2005 Statut Membre Dernière intervention 16 mai 2008 - 15 mai 2008 à 15:20
abdo77 Messages postés 3 Date d'inscription mercredi 25 mai 2005 Statut Membre Dernière intervention 16 mai 2008 - 16 mai 2008 à 17:01
merci de votre aide
je travaille avec eclipse 3.3.2
mon probleme est que les get et set de la la classe actionFrom ne fonctionnne pas bien.
package med.dao;
import org.apache.struts.action.*;
import javax.servlet.http.*;


import org.apache.struts.action.ActionForm;


public class Formbean extends ActionForm {
 private int cin;
 public int getCin()
 {
  
  return cin;
 }
 void setCin(int cin)
{this.cin=cin;
 
}
 }

package med.action;


import java.io.IOException;


import org.apache.struts.action.*;
import javax.servlet.http.*;




import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.hibernate.HibernateException;
import med.dao.Client;
import med.dao.Formbean;
import med.managers.ClientManager;


public class Mon_action extends Action{
  public ActionForward execute(
    ActionMapping mapping,
    ActionForm form,
  HttpServletRequest request,
  HttpServletResponse response) throws IOException,ServletException,Exception {
   
   Formbean formulaire=(Formbean) form;
   System.out.println("cin="+formulaire.getCin());
// ici il m'affiche 0



Client monclient=tt.getCompany(formulaire.getCin());










request.setAttribute(
"nom"

, monclient.getNom());

request.setAttribute(




"prenom"

,monclient.getPrenom());











    return mapping.findForward("ok");
  
  }
}

voila ma page index.jsp qui contient un formulaire qui contient le champ cin:
<%@

taglib uri=
"/WEB-INF/struts-bean.tld" prefix=
"bean" %><%@

taglib uri=
"/WEB-INF/struts-html.tld" prefix=
"html" %><%@

taglib uri=
"/WEB-INF/struts-logic.tld" prefix=
"logic" %><%@

taglib uri=
"/WEB-INF/struts-nested.tld" prefix=
"nested" %><%@

taglib uri=
"/WEB-INF/struts-template.tld" prefix=
"template" %><%@

taglib uri=
"/WEB-INF/struts-tiles.tld" prefix=
"tiles" %><%@

page language=
"java" %><

html:html locale=
"true">

<head>

<title>Authentification
</title>

<html:base/>

</head>

<body bgcolor=
"white">

<html:form action=
"main" >

<html:text property=
"cin" size=
"20" maxlength=
"20"/>

<html:submit property=
"submit" value=
"OK"/>

</html:form>

</body></

html:html>

et la page affiche qui doit afficher les info lié à ce champs
<%@

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><%

String nom=(String)request.getAttribute(

"nom");String prenom=(String)request.getAttribute(

"prenom");

%>

</

body>nom:

<%=nom
%><

br>prenom:
<%=prenom
%>
</

html>

 

2 réponses

cs_DARKSIDIOUS Messages postés 15814 Date d'inscription jeudi 8 août 2002 Statut Membre Dernière intervention 4 mars 2013 130
15 mai 2008 à 19:13
Salut,

Ce ne sont pas les get/set qui ne fonctionnent pas bien, montre nous ton fichier struts-config.
______________________________________
DarK Sidious
0
abdo77 Messages postés 3 Date d'inscription mercredi 25 mai 2005 Statut Membre Dernière intervention 16 mai 2008
16 mai 2008 à 17:01
oui, voila mon fichier struts-config



<?



xml
version
=

"1.0"
encoding
=

"ISO-8859-1"
?><!


DOCTYPE
struts-config
PUBLIC

"-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"




"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd"



><


struts-config
><


form-beans
><


form-bean
name
=

"a"
type
=

"med.dao.Formbean"
/>







</



form-beans
>







<



action-mappings
>






<
action
input
=

"/index.jsp"
path
=

"/main"


name
=

"a"
type
=

"med.action.Mon_action"
><


forward
name
=

"ok"
path
=

"/affiche.jsp"
/></


action
></


action-mappings
></


struts-config
>
et mon fichier web.xml



<?



xml
version
=

"1.0"
encoding
=

"UTF-8"
?><!


DOCTYPE
web-app
PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd"
><


web-app
>






<
display-name
>
telMed

</
display-name
>






<
servlet
>






<
servlet-name
>
action

</
servlet-name
>






<
servlet-class
>
org.apache.struts.action.ActionServlet

</
servlet-class
>






<
init-param
>






<
param-name
>
config

</
param-name
>






<
param-value
>
/WEB-INF/struts-config.xml

</
param-value
>






</
init-param
>






<
init-param
>






<
param-name
>
debug

</
param-name
>






<
param-value
>
2

</
param-value
>






</
init-param
>






<
init-param
>






<
param-name
>
application

</
param-name
>






<
param-value
>
ApplicationResources

</
param-value
>






</
init-param
>






<
load-on-startup
>
2

</
load-on-startup
>






</
servlet
>






<
servlet-mapping
>






<
servlet-name
>
action

</
servlet-name
>






<
url-pattern
>
*.do

</
url-pattern
>






</
servlet-mapping
>






<
taglib
>






<
taglib-uri
>
/WEB-INF/struts-bean.tld

</
taglib-uri
>






<
taglib-location
>
/WEB-INF/struts-bean.tld

</
taglib-location
>






</
taglib
>






<
taglib
>






<
taglib-uri
>
/WEB-INF/struts-html.tld

</
taglib-uri
>






<
taglib-location
>
/WEB-INF/struts-html.tld

</
taglib-location
>






</
taglib
>






<
taglib
>






<
taglib-uri
>
/WEB-INF/struts-logic.tld

</
taglib-uri
>






<
taglib-location
>
/WEB-INF/struts-logic.tld

</
taglib-location
>






</
taglib
>






<
taglib
>






<
taglib-uri
>
/WEB-INF/struts-template.tld

</
taglib-uri
>






<
taglib-location
>
/WEB-INF/struts-template.tld

</
taglib-location
>






</
taglib
>






<
taglib
>






<
taglib-uri
>
/WEB-INF/struts-tiles.tld

</
taglib-uri
>






<
taglib-location
>
/WEB-INF/struts-tiles.tld

</
taglib-location
>






</
taglib
>






<
taglib
>






<
taglib-uri
>
/WEB-INF/struts-nested.tld

</
taglib-uri
>






<
taglib-location
>
/WEB-INF/struts-nested.tld

</
taglib-location
>






</
taglib
></


web-app
>
 
0
Rejoignez-nous