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 affichage depuis base de données


Sujet :

Struts 1 Java

  1. #1
    Nouveau candidat au Club
    Inscrit en
    Avril 2008
    Messages
    1
    Détails du profil
    Informations forums :
    Inscription : Avril 2008
    Messages : 1
    Par défaut probleme affichage depuis base de données
    Bonjour, je sui debutant en struts et je narrive po a regler un problem depui klk jours
    En fait je ve lister une table de clients dan une page jsp, mai je rencontre tjrs un problem de type :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    message No action instance for path /viewClients could be

    Je vous montre mon fichier 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
    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
     
    <?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="agentForm" type="com.sat.struts.form.AgentForm" />
    <form-bean name="vodForm" type="com.sat.struts.form.VodForm" />
    <form-bean name="clientForm" type="com.sat.struts.form.ClientForm" />
    </form-beans>
     
    <action-mappings>
     
    <action 
             attribute="agentForm"
             name="agentForm"
             input="/form/home.jsp"
             path="/home"
             scope="request"
             type="com.sat.struts.action.SubmitAction">
             <forward name="failure" path="/form/errorLogin.jsp" />
             <forward name="success" path="/form/menu.jsp" />
    </action>
     
    <action 
              attribute="agentForm"
              name="agentForm"
              parameter="do"
              path="/viewUsers"
     
              scope="request"
              type="com.sat.struts.action.UsersListAction">
      		  <forward name="showList" path="/form/usersList.jsp" />
      		  <forward name="showListAfterDelete" path="/viewUsers.do?do=showUsers" />
     
    </action>
     
    <action 
              attribute="clientForm"
              name="clientForm"
              parameter="do"
              path="/viewClients"
     
              scope="request"
              type="com.sat.struts.action.ClientsListAction">
      		  <forward name="showList" path="/form/clientsList.jsp" />
      		  <forward name="showListAfterDelete" path="/viewClients.do?do=showClients" />
     
    </action>
     
     
    <action 
      		  path="/logout"
              type="com.sat.struts.action.LogoutAction">
              <forward name="logout" path="/form/home.jsp" />
    </action>
     
    <action 
              attribute="vodForm"
              name="vodForm"
              parameter="do"
              path="/viewVods"
              input="/form/vod.jsp"
              scope="request"
              type="com.sat.struts.action.VodListAction">
      		  <forward name="showList" path="/form/VodList.jsp" />
      		  <forward name="showListAfterDelete" path="/viewVods.do?do=showVods" />
      </action>
     
     
    </action-mappings>
    <message-resources parameter="com.sat.struts.ApplicationResources.properties"/>
    </struts-config>

    Voici mon 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
    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
     
    package com.sat.struts.action;
     
    import java.sql.SQLException;
    import java.util.Collection;
     
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
     
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
    import org.apache.struts.actions.DispatchAction;
     
     
    import com.sat.metier.Agent;
    import com.sat.struts.form.ClientForm;
     
     
     
     
    public class ClientsListAction extends DispatchAction{
     
    	public ActionForward deleteClient(
    			ActionMapping mapping,
    			ActionForm form,
    			HttpServletRequest request,
    			HttpServletResponse response) throws SQLException {
    			//ClientForm clientForm = (ClientForm) form;
    			String nom =request.getParameter("nom");
     
    			Agent user = new Agent();
    			user.deleteByNom(nom);
     
    			return mapping.findForward("showListAfterDelete");
    		}
     
     
     
    		public ActionForward showClients(
    				ActionMapping mapping,
    				ActionForm form,
    				HttpServletRequest request,
    				HttpServletResponse response) {
    				ClientForm clientForm = (ClientForm) form;
     
     
     
     
    				Agent user = new Agent();
    				Collection c;
    				try {
    					c = (Collection) user.Lister3();
     
    					 System.out.println(c.toString());
    					clientForm.setClients(c);
     
     
    					System.out.println("la collection est remplie");
    				} catch (Exception e) {
    					// TODO Auto-generated catch block
    					e.printStackTrace();
    				}
     
     
    				return mapping.findForward("showList");
    			}
    et voici le code de ma page jsp

    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
     
    </style></head>
     
    <body>
    <table width="162" height="88" border="1" align="right">
        <tr>
          <td width="152" height="82"><img src="/sat/form/images/logo_meditel.jpg" width="152" height="77"></td>
        </tr>
      </table>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <table width="335" border="1" align="center">
      <tr>
        <td width="325"><p class="Style1">LA LISTE DES CLIENTS EN TRAITEMENT </p>    </td>
      </tr>
    </table>
    <p>&nbsp;</p>
    <table width="757" border="1">
      <tr>
        <td class="Style1">CLIENT</td>
        <td class="Style1">ADRESSE</td>
     
      </tr>
      <logic:empty name="clientForm" property="clients">
    <tr>
    <td colspan="5">Tous Les Clients Sont Servis</td>
    </tr>
    	</logic:empty>
    		<logic:notEmpty name="clientForm" property="clients">
    		<logic:iterate name="clientForm" property="clients" id="client">
    <tr>
     
    			<td width="325"><p class="Style1"><bean:write name="client" property="nom" /></td>
    			<td width="325"><p class="Style1"><bean:write name="client" property="adresse" /></td>
     
     
     
     
    		</logic:iterate>
    		</logic:notEmpty>
    </table>
    <p>&nbsp;</p>
     
    <div align="center"><span class="Style4"><a href="/sat/form/menu.jsp" class="Style2">RETOUR AU MENU PRINCIPAL</a> </span></div>
    </body>
    </html>
    SVP aidez moi
    merci davance

  2. #2
    Membre éclairé Avatar de Tanebisse
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Février 2007
    Messages
    449
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Industrie

    Informations forums :
    Inscription : Février 2007
    Messages : 449
    Par défaut
    Si tu utilise une action de type DispatchAction tu dois alors avoir un parametre dans ton struts-config nommé "hidden". Tu dois ensuite le valoriser dans ta JSP, la valeur que tu lui donne est le nom de la méthode a appeler dans ta classe DispatchAction, ex :
    Struts-config
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    <action 
              attribute="clientForm"
              name="clientForm"
              parameter="hidden"
              path="/viewClients"       
              scope="request"
              type="com.sat.struts.action.ClientsListAction">
      		  <forward name="showList" path="/form/clientsList.jsp" />
      		  <forward name="showListAfterDelete" path="/viewClients.do?do=showClients" />
      		  
    </action>
    Dans ta JSP :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    <html:form action="/afficherQualite" styleId="qualiteForm">
    	<html:hidden styleId="hidden" property="hidden" value="showClients"/>
    </html:form>

Discussions similaires

  1. Probleme avec module base de donnée
    Par k_boy dans le forum Bases de données
    Réponses: 5
    Dernier message: 20/07/2007, 19h51
  2. probleme recherche dans base de donnée
    Par 0kiss0 dans le forum ASP
    Réponses: 3
    Dernier message: 16/04/2007, 18h50
  3. Probleme avec Module Base de données (dbd32.exe)
    Par mekdar dans le forum Bases de données
    Réponses: 3
    Dernier message: 25/10/2005, 13h45
  4. probleme avec une base de donnée postgres SQL
    Par Alexlesilex dans le forum Bases de données
    Réponses: 1
    Dernier message: 19/06/2005, 22h09

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