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 :

[Débutant] Erreur inconnue


Sujet :

Struts 1 Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éprouvé Avatar de Le Pharaon
    Profil pro
    Inscrit en
    Mai 2004
    Messages
    880
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2004
    Messages : 880
    Par défaut [Débutant] Erreur inconnue
    J'essaye de tester un exemple du livre "Développement Java sous Struts" mais quand j'execute l'application je reçois dans le navigateur "La ressource demandée (/FirstStruts/) n'est pas disponible." alors que dans tomcat je ne vois aucun message d'erreur.

    bean de modèle (je ne l'ai pas encore utilisé)
    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
    package ddd.pharaon.javabeans;
     
    import java.io.Serializable;
     
    public class Login implements Serializable {
    private static final long serialVersionUID = 1L;
    private String login = null;
    private String mdp=null;
     
      public String getLogin() {
      return login;
      }
     
      public void setLogin(String login) {
        this.login = login;
      }
     
      public String getMdp() {
      return mdp;
      }
     
      public void setMdp(String mdp) {
        this.mdp = mdp;
      }
     
    }
    Action
    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
    package ddd.pharaon.action;
     
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
     
    import org.apache.commons.beanutils.*;
    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 ddd.pharaon.actionform.LoginForm;
    import ddd.pharaon.javabeans.Login;
     
    public class LoginAction extends Action {
      public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,HttpServletResponse response ) 
           throws Exception {
     
     LoginForm monLoginForm = (LoginForm) form;
     Login monLogin = new Login();
     
     BeanUtils.copyProperties(monLogin, monLoginForm);
     request.setAttribute(mapping.getAttribute(),monLogin);
     
     if (monLogin.getLogin().equals ("jcf") && monLogin.getMdp().equals("jcf")){
      return mapping.findForward("success");
     }
      return mapping.findForward("erreur");
     
      }
    }
    ActionForm
    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
    package ddd.pharaon.actionform;
     
    import org.apache.struts.action.ActionForm;
     
    public class LoginForm extends ActionForm {
    private static final long serialVersionUID = 2L;
    private String login = null;
    private String mdp=null;
     
      public String getLogin() {
      return login;
      }
     
      public void setLogin(String login) {
        this.login = login;
      }
     
      public String getMdp() {
      return mdp;
      }
     
      public void setMdp(String mdp) {
        this.mdp = mdp;
      }
     
    }
    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
    69
    <?xml version="1.0" encoding="ISO-8859-1"?>
     
    <!DOCTYPE web-app
      PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
      "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
     
    <web-app>
      <display-name>Struts Blank Application</display-name>
     
      <!-- Standard Action Servlet Configuration (with debugging) -->
      <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>
     
     
      <!-- Standard Action Servlet Mapping -->
      <servlet-mapping>
        <servlet-name>action</servlet-name>
        <url-pattern>*.do</url-pattern>
      </servlet-mapping>
     
     
      <!-- The Usual Welcome File List -->
      <welcome-file-list>
        <welcome-file>/pages/loginForm.jsp</welcome-file>
      </welcome-file-list>
     
     
      <!-- Struts Tag Library Descriptors -->
      <taglib>
        <taglib-uri>/tags/struts-bean</taglib-uri>
        <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
      </taglib>
     
      <taglib>
        <taglib-uri>/tags/struts-html</taglib-uri>
        <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
      </taglib>
     
      <taglib>
        <taglib-uri>/tags/struts-logic</taglib-uri>
        <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
      </taglib>
     
      <taglib>
        <taglib-uri>/tags/struts-nested</taglib-uri>
        <taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
      </taglib>
     
      <taglib>
        <taglib-uri>/tags/struts-tiles</taglib-uri>
        <taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
      </taglib>
     
    </web-app>
    struts-config.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
    <?xml version="1.0" encoding="ISO-8859-1" ?>
     
    <!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="LoginForm"
          type="ddd.pharaon.actionform.LoginForm"/>
       </form-beans>
       <action-mappings>
     
         <action 
           path = "/InputSubmit"
           forward = "ddd.pharaon.action.LoginAction" 
           name="LoginForm"
           scope="request"
           attribute = "login"
           input="/pages/loginForm.jsp">
           <forward name="success" path = "/pages/loginSuccess.jsp"></forward>
           <forward name="erreur" path = "/pages/erreur.jsp"></forward>
         </action>              
       </action-mappings>
       <message-resources parameter = "java.MessageResources" />
    </struts-config>
    Nota :
    Les pages jsp se trouvent dans le repéertoire WEB-INF/pages
    EDI : Eclipse

    Merci

  2. #2
    Membre émérite
    Profil pro
    Développeur Back-End
    Inscrit en
    Avril 2003
    Messages
    782
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Back-End

    Informations forums :
    Inscription : Avril 2003
    Messages : 782
    Par défaut
    Bonjour,

    Si les pages jsp sont dans le répertoire Web-Inf il faut :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
           input="/WEB-INF/pages/loginForm.jsp">
           <forward name="success" path = "/WEB-INF/pages/loginSuccess.jsp"></forward>

  3. #3
    Membre éprouvé Avatar de Le Pharaon
    Profil pro
    Inscrit en
    Mai 2004
    Messages
    880
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2004
    Messages : 880
    Par défaut
    Merci fnobb pour ton coup de main.
    J'ai apporté ce changement juste dans le repertoire web.xml et ai laissé le struts-config intact, et ça marche.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <welcome-file>/WEB-INF/pages/loginForm.jsp</welcome-file>
    Une nouvelle erreur :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    java.lang.IllegalArgumentException: Le chemin ddd.pharaon.action.LoginAction ne commence pas par le caractère "/"

  4. #4
    Membre émérite
    Profil pro
    Développeur Back-End
    Inscrit en
    Avril 2003
    Messages
    782
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Back-End

    Informations forums :
    Inscription : Avril 2003
    Messages : 782
    Par défaut
    il faudra ajouter le Web-inf partout !
    de plus dans le Strut-config.xml
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    <action 
           path = "/InputSubmit"
           type= "ddd.pharaon.action.LoginAction" 
           name="LoginForm"
           scope="request"
           attribute = "login"

  5. #5
    Membre éprouvé Avatar de Le Pharaon
    Profil pro
    Inscrit en
    Mai 2004
    Messages
    880
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2004
    Messages : 880
    Par défaut
    Citation Envoyé par fnobb
    il faudra ajouter le Web-inf partout !
    de plus dans le Strut-config.xml
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    <action 
           path = "/InputSubmit"
           type= "ddd.pharaon.action.LoginAction" 
           name="LoginForm"
           scope="request"
           attribute = "login"
    J'ai toujours l'erreur.

  6. #6
    Membre émérite
    Profil pro
    Développeur Back-End
    Inscrit en
    Avril 2003
    Messages
    782
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Back-End

    Informations forums :
    Inscription : Avril 2003
    Messages : 782
    Par défaut
    Citation Envoyé par Le Pharaon
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    java.lang.IllegalArgumentException: Le chemin ddd.pharaon.action.LoginAction ne commence pas par le caractère "/"
    cette erreur vient du
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    forward = "ddd.pharaon.action.LoginAction"
    pour definir la classe Action associée à l'action c'est
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    type = "ddd.pharaon.action.LoginAction"
    pour la variable forward, il attend un chemin (qui commence donc par \ )

  7. #7
    Membre éprouvé Avatar de Le Pharaon
    Profil pro
    Inscrit en
    Mai 2004
    Messages
    880
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2004
    Messages : 880
    Par défaut
    Quelle connerie

    Merci encore fnobb

  8. #8
    Membre éprouvé Avatar de Le Pharaon
    Profil pro
    Inscrit en
    Mai 2004
    Messages
    880
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2004
    Messages : 880
    Par défaut
    Une autre erreur au niveau de la page erreur.jsp. Le lien ne marche pas
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    <%@ taglib uri= "/tags/struts-bean" prefix ="bean" %>
    <%@ taglib uri= "/tags/struts-html" prefix ="html" %>
    <%@ taglib uri= "/tags/struts-logic" prefix ="logic" %>
    
    <html:html>
    <head>
    <title>Page Login</title>
    <body>
    <h4>Login ou mot de passe incorrect </h4>
    <html:link href="WEB-INF/pages/loginForm.jsp">Recommencer</html:link>
    </body>
    </html:html>

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

Discussions similaires

  1. [débutant] Erreur de compilation inconnue
    Par jimay dans le forum Débuter
    Réponses: 3
    Dernier message: 14/05/2007, 11h55
  2. [Débutant] Problemes erreurs inconnues
    Par jnagone dans le forum Ruby
    Réponses: 4
    Dernier message: 23/02/2007, 00h54
  3. Réponses: 7
    Dernier message: 01/06/2005, 11h48
  4. erreur inconnue
    Par naw dans le forum Bases de données
    Réponses: 5
    Dernier message: 02/02/2005, 08h51
  5. [Débutant]Erreur compilation !
    Par gandalf_le_blanc dans le forum AWT/Swing
    Réponses: 23
    Dernier message: 30/08/2004, 14h23

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