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 1 Java Discussion :

probleme d'affichage avec struts 1.2.4


Sujet :

Struts 1 Java

  1. #1
    Nouveau membre du Club
    Inscrit en
    Février 2007
    Messages
    74
    Détails du profil
    Informations forums :
    Inscription : Février 2007
    Messages : 74
    Points : 35
    Points
    35
    Par défaut probleme d'affichage avec struts 1.2.4
    bonjour,

    je viens de telecharger struts-lib 1.2.4 depuis le site apache

    et je veux commencer a utiliser struts

    j'ai copier les fichiers.jar dans le dossier /WEB-INF/lib et le fichiers .tld dans /WEB-INF et j'ai les ajouter dans le fichier web.xml :

    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
    65
    66
    67
    68
     
     
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4">
      <display-name>Tester Struts 1.2.4</display-name>
     
      <!-- Servlet controleur de Struts -->
      <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>detail</param-name>
          <param-value>2</param-value>
        </init-param>
        <load-on-startup>2</load-on-startup>
      </servlet>
     
      <!-- Mapping des url avec la servlet -->
      <servlet-mapping>
        <servlet-name>action</servlet-name>
        <url-pattern>*.do</url-pattern>
      </servlet-mapping>
     
      <!-- page d'accueil de l'application -->
      <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
      </welcome-file-list>
     
     
        <!-- Descripteur des bibliotheques personnalisees de Struts -->
        <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-nested.tld</taglib-uri>
          <taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
        </taglib>
     
        <taglib>
          <taglib-uri>/WEB-INF/struts-tiles.tld</taglib-uri>
          <taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
        </taglib>
     
     
    </web-app>
    le fichier struts-config :
    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
     
     
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
     
     
    <struts-config>
     
    	<form-beans> 
        	<form-bean name="form" type="LoginForm" /> 
      	</form-beans>
     
    	<action-mappings>	
     
    			<action 
          		path="/log" 
    			name="form" 
    			scope="session" 
    			validate="true" 
    			input="/err.do" 
    			parameter="/rep.do" 
    			type="org.apache.struts.actions.ForwardAction" />
     
    		<action path="/idx" parameter="/index.jsp" type="org.apache.struts.actions.ForwardAction" /> 
    		<action path="/rep" parameter="/JSPs/reponses.jsp" type="org.apache.struts.actions.ForwardAction" />
    		<action path="/err" parameter="/JSPs/erreurs.jsp" type="org.apache.struts.actions.ForwardAction" />
    	</action-mappings>
     
    	<message-resources parameter="ressources"/>
    </struts-config>
    et dans la page index.jsp j'ai mis le code suivant :

    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
     
    <%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
     
    <%@ 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" %>
    <html>
      <head>
        <title>Authentification</title>
      </head>
      <body bgcolor="white">
     
    	<center> 
          <h2>Personne - formulaire</h2> 
          <hr> 
          <html:form action="/log" name="form" type="LoginForm" focus="nom"> 
           <table width="225" height="96"> 
             <tr> 
               <td width="137">Username :</td> 
               <td width="76"><html:text property="nom" size="20" /></td> 
             </tr> 
              <tr> 
               <td>Password :</td> 
                <td><html:password property="psw" size="20"/></td> 
              </tr> 
             <tr> 
            </table> 
            <table> 
             <tr> 
               <td><html:submit value="Envoyer"/></td> 
                <td><html:reset value="Rétablir"/></td> 
              </tr> 
            </table> 
          </html:form> 
        </center> <br />
     
     
      </body>
    </html>
    le bean avec la methode validate :

    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
     
    import javax.servlet.http.HttpServletRequest;
    import org.apache.struts.action.ActionErrors;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionMapping;
    import org.apache.struts.action.ActionMessage;
     
    public class LoginForm extends ActionForm 
    {
    	/**
             * 
             */
    	private static final long serialVersionUID = 1L;
    	private String nom= null;
    	private String psw=null;
     
    	public LoginForm(){}
     
    	public String getNom() {
    		return nom;
    	}
     
    	public void setNom(String nom) {
    		this.nom = nom;
    	}
     
    	public String getPsw() {
    		return psw;
    	}
     
    	public void setPsw(String psw) {
    		this.psw = psw;
    	}
     
    	public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) 
    	{  
    	    ActionErrors erreurs = new ActionErrors(); 
    	    if (nom == null || nom.trim().equals("")) 
    	    { 
    	      erreurs.add("nomvide", new ActionMessage("errors.nom.vide"));  
    	    } 
    	    if (psw == null || psw.trim().equals("")) 
    	    { 
    	      erreurs.add("pswvide", new ActionMessage("errors.psw.vide")); 
    	    } 
    	    return erreurs; 
    	  } 
    }

    en lançant Tomcat 6.0.18 j'ai cette erreur bizzare :
    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
     
     
    org.apache.jasper.JasperException: /index.jsp(15,6) L'attribut name est incorrect pour le tag form d'apr�s la TLD indiqu�e
    	org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
    	org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
    	org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:236)
    	org.apache.jasper.compiler.Validator$ValidateVisitor.checkXmlAttributes(Validator.java:1200)
    	org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:821)
    	org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1512)
    	org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)
    	org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2393)
    	org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2399)
    	org.apache.jasper.compiler.Node$Root.accept(Node.java:489)
    	org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)
    	org.apache.jasper.compiler.Validator.validate(Validator.java:1739)
    	org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:166)
    	org.apache.jasper.compiler.Compiler.compile(Compiler.java:315)
    	org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
    	org.apache.jasper.compiler.Compiler.compile(Compiler.java:282)
    	org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
    	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
    	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    et en actualisant la page j'obtient une autre erreur
    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
     
    org.apache.jasper.JasperException: org.apache.jasper.JasperException: Impossible de charger la classe pour la JSP
    	org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:156)
    	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:329)
    	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
     
    cause m�re
     
    org.apache.jasper.JasperException: Impossible de charger la classe pour la JSP
    	org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:620)
    	org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:144)
    	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:329)
    	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
     
    cause m�re
     
    java.lang.ClassNotFoundException: org.apache.jsp.index_jsp
    	java.net.URLClassLoader$1.run(Unknown Source)
    	java.security.AccessController.doPrivileged(Native Method)
    	java.net.URLClassLoader.findClass(Unknown Source)
    	org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:134)
    	org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:66)
    	org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:618)
    	org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:144)
    	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:329)
    	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

    je ne vois pas ou est l'erreur tous les fichiers sont mis dans leurs dossiers

    veuillez m'aider SVP et merci

  2. #2
    Expert éminent

    Femme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    5 793
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations forums :
    Inscription : Juillet 2005
    Messages : 5 793
    Points : 7 778
    Points
    7 778
    Par défaut
    En Struts 1.2.4, les attributs name et type n'existent pas dans le tag html:form. Ils existaient en Struts 1.0 et 1.1.

    Il suffit juste de coder ceci :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
          <html:form action="/log" focus="nom">

  3. #3
    Nouveau membre du Club
    Inscrit en
    Février 2007
    Messages
    74
    Détails du profil
    Informations forums :
    Inscription : Février 2007
    Messages : 74
    Points : 35
    Points
    35
    Par défaut
    Citation Envoyé par c_nvy Voir le message
    En Struts 1.2.4, les attributs name et type n'existent pas dans le tag html:form. Ils existaient en Struts 1.0 et 1.1.

    Il suffit juste de coder ceci :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
          <html:form action="/log" focus="nom">
    merci, je vais repmlacer le code par celui que vous m'avez donné
    est ce que je dois modifier quelque chose dans le fichier de configuration de struts ???

  4. #4
    Nouveau membre du Club
    Inscrit en
    Février 2007
    Messages
    74
    Détails du profil
    Informations forums :
    Inscription : Février 2007
    Messages : 74
    Points : 35
    Points
    35
    Par défaut
    merci ca fonctionne bien
    si vous voulez j'ai des questions a vous poser ^^

    comment le controleur va reconnaitre le formulaire s'il s'agit de plusieurs formulaire est ce que c'est le javabeans qui fait cela ?

    et pour ne pas avoir d'erreur par la suite s'il n y'a pas de name pour le formulaire a quoi va me servir l'attribut name du formulaire dans la balise <action> ? et <form-bean> ?

    et encore un grand merci

  5. #5
    Expert éminent

    Femme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    5 793
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations forums :
    Inscription : Juillet 2005
    Messages : 5 793
    Points : 7 778
    Points
    7 778
    Par défaut
    Comme tu as spécifié l'attribut name="form" dans le mapping de l'Action de path /log, lorsque tu référénces ce path /log dans l'attribut action du tag html:form, il sait que le form-bean lié à l'Action est form.

  6. #6
    Nouveau membre du Club
    Inscrit en
    Février 2007
    Messages
    74
    Détails du profil
    Informations forums :
    Inscription : Février 2007
    Messages : 74
    Points : 35
    Points
    35
    Par défaut
    je comprends maintenant merci beaucoup

    et pour acceder a une base de donnes MySQL a part celui de Mr.serge.tahe
    existent t'ils des tutos ?

    (desole j'ai pas remarqué que j'ai pas teminé la phrase)

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Probleme d'affichage avec un DataGridView
    Par kekesilo dans le forum Windows Forms
    Réponses: 3
    Dernier message: 30/01/2007, 14h12
  2. Probleme d'affichage avec TextOutA
    Par NouRSS dans le forum C++Builder
    Réponses: 3
    Dernier message: 27/05/2006, 15h01
  3. [Graphic2D] Probleme d'affichage avec drawLine()
    Par Yannick_from_31 dans le forum 2D
    Réponses: 12
    Dernier message: 23/05/2006, 18h09
  4. Problème d'affichage avec top
    Par HacHHacH dans le forum Shell et commandes GNU
    Réponses: 1
    Dernier message: 03/04/2006, 01h25
  5. Réponses: 6
    Dernier message: 10/11/2005, 08h58

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