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 :

Error - tag.getAsString : component context is not defined. Check tag syntax


Sujet :

Struts 1 Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre du Club
    Inscrit en
    Février 2008
    Messages
    10
    Détails du profil
    Informations forums :
    Inscription : Février 2008
    Messages : 10
    Par défaut Error - tag.getAsString : component context is not defined. Check tag syntax
    Bonjour ,

    Merci d'avance à ceux qui pourront m'aider.

    Je m'appuie sur les exercices du livre De Jean Charles FELICITE Développement Java sous STRUTS 1.2 ,chapitre 6 sur l'utilisation des tiles.

    A l'exécution j'ai le message d'erreur ci-dessous.
    Error - tag.getAsString : component context is not defined. Check tag syntax

    struts-config.xml :
    Code XML : 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
    <?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>    
    <!-- =========================================== Global Forward Definitions -->
        <global-forwards>
            <!-- Default forward to "Welcome" action -->
            <!-- Demonstrates using index.jsp to forward -->
            <forward
                name="welcome"
                path="/Welcome.do"/>
     
            <forward
                name="index"
                path="/index.do"/>
     
        </global-forwards>    
     
     
    <!--  ********************** Mapping *********************** -->   
        <action-mappings>     
                <!-- Default "Welcome" action -->
                <!-- Forwards to Welcome.jsp -->
            <action
                path="/Welcome"
                forward="/pages/Welcome.jsp" />
     
            <action
                path="/index"            
                forward="modele1" />
     
        </action-mappings>
     
        <message-resources parameter="fr.edition.eni.ressources.mesMessages" />
     
        <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
        	<set-property
            	property="pathnames"
    	        value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
        	</plug-in>
     
     
        <plug-in className="org.apache.struts.tiles.TilesPlugin"> 
        <set-property property="definitions-config"
    										value="/WEB-INF/tiles-defs.xml" />
        <set-property property="moduleAware" value="true" />
        <set-property property="definitions-parser-validate" value="true" />
       </plug-in>
        </struts-config>
    web.xml :
    Code XML : 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
    <?xml version="1.0" encoding="ISO-8859-1"?>
     
      <!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>Struts Blank Application</display-name>
     
      <!-- Standard Action Servlet Configuration -->
      <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>
        <init-param>
            <param-name>chainConfig</param-name>
            <param-value>org/apache/struts/tiles/chain-config.xml</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>index.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>
     
      <taglib>
        <taglib-uri>/tags/MesTagsPerso</taglib-uri>
        <taglib-location>/WEB-INF/MesTags.tld</taglib-location>
      </taglib>
    </web-app>
    tiles-defs.xml :
    Code XML : 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
    <?xml version="1.0" encoding="UTF-8" ?>
     
     <!DOCTYPE tiles-definitions PUBLIC
           "-//Apache Software Foundation//DTD Tiles Configuration 1.1//EN"
           "tiles-config_1_1.dtd">
     
     
    <tiles-definitions>
     
        <!-- sample tiles definitions-->
        <definition  name="modele1" path="/index.jsp">
            <put name="titre"  value="Titre de la page principale"/>
            <put name="entete" value="/pages/tiles/entete.jsp" />
            <put name="menu"   value="/pages/tiles/menu.jsp" />
            <put name="pied" value="/pages/tiles/pied.jsp" />
          	<put name="corps"  value="body" /> 
     
        </definition>
        <definition name="modele2" path="/index2.jsp" extends="modele1">
       		<put name="titre"  value="Titre de la page secondaire"/>
       		<put name="corps"  value="body" /> 
        </definition>
     
        <definition name="body" path="/pages/tiles/corps.jsp">
            <put name="liens"  value="/pages/tiles/liens.jsp" />
            <put name="news"  value="/pages/tiles/news.jsp" />
        </definition>
     
        <definition name="body2" path="/pages/tiles/corps.jsp" >
            <put name="liens"  value="/pages/tiles/liens2.jsp" />
            <put name="news"  value="/pages/tiles/news2.jsp" />
        </definition>
     
    </tiles-definitions>
    index.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
    <%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
     
    <html>
     
    <head>
    	<title><tiles:getAsString name="titre" ignore="true"/></title>
    </head>
     
    <body>
    <table border="0" width="100%" cellspacing="5">
    <tr>
    <td colspan="2"><tiles:insert attribute="entete" /></td>
    </tr>
    <tr>
    <td width="200" valign="top">
    <tiles:insert attribute="menu"/>
    </td>
    <td valign="top" align="left">
    <tiles:insert attribute="corps" />
    </td>
    </tr>
    <tr>
    <td colspan="2">
    <tiles:insert attribute="pied" />
    </td>
    </tr>
    </table>
    </body>
    </html>

  2. #2
    Membre confirmé
    Développeur informatique
    Inscrit en
    Juillet 2007
    Messages
    167
    Détails du profil
    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Juillet 2007
    Messages : 167
    Par défaut
    N'aurais tu pas oublié de declarer ta servlet et de préciser où se trouve le fichier de conf des tiles dans web.xml?

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    <servlet-class>org.apache.struts.tiles.ActionComponentServlet</servlet-class>
        <init-param>
            <param-name>definitions-config</param-name>
            <param-value>/WEB-INF/tileDefinitions.xml</param-value>
        </init-param>
    PS: faute de n'avoir trouvé sur developpez.com, je dirai merci javaworld.com

    PS: Je suis en aucun cas un expert de ce mode de fonctionnement des tiles.

  3. #3
    Membre du Club
    Inscrit en
    Février 2008
    Messages
    10
    Détails du profil
    Informations forums :
    Inscription : Février 2008
    Messages : 10
    Par défaut erreur tag
    Je débute avec struts et on peut dire que c'est pas si simple
    A priori la définition tiles se fait dans struts-config.xml depuis la version 1.2.

    J'ai quand même essayé mais j'ai toujours un message d'erreur
    je rajoute l'erreur complète.

    StandardWrapperValve[jsp]: "Servlet.service()" pour la servlet jsp a généré une exception
    javax.servlet.ServletException: Error - tag.getAsString : component context is not defined. Check tag syntax
    at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:495)
    at org.apache.jsp.index_jsp._jspService(index_jsp.java:80)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:92)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:162)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:240)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:187)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:200)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:146)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:209)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:144)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
    at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2358)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:133)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)

  4. #4
    Membre confirmé
    Développeur informatique
    Inscrit en
    Juillet 2007
    Messages
    167
    Détails du profil
    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Juillet 2007
    Messages : 167
    Par défaut
    je viens de vérifier ton struts-config, ton forward n'est pas bon. Tu dois faire référence à la valeur que tu souhaites afficher de ton tiles-defs.xml. Essaies :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <forward name="index" path="modele1"/>

  5. #5
    Membre du Club
    Inscrit en
    Février 2008
    Messages
    10
    Détails du profil
    Informations forums :
    Inscription : Février 2008
    Messages : 10
    Par défaut
    Comme ci-dessous.Ca fait toujours la même chose.

    Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    <!-- =========================================== Global Forward Definitions -->
        <global-forwards>
            <!-- Default forward to "Welcome" action -->
            <!-- Demonstrates using index.jsp to forward -->
            <forward
                name="welcome"
                path="/Welcome.do"/>
     
    <!--		<forward
                name="index"
                path="/index.do"/>     -->
    		<forward name="index" path="modele1"/>
        </global-forwards>

  6. #6
    Membre confirmé
    Développeur informatique
    Inscrit en
    Juillet 2007
    Messages
    167
    Détails du profil
    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Juillet 2007
    Messages : 167
    Par défaut
    dans ton struts config, declares ton fichier de description
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    <plug-in className="org.apache.struts.tiles.TilesPlugin">
      <set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml" /> 
      </plug-in>

  7. #7
    Membre du Club
    Inscrit en
    Février 2008
    Messages
    10
    Détails du profil
    Informations forums :
    Inscription : Février 2008
    Messages : 10
    Par défaut
    c'est fait .

    ça fait une semaine que je cherche la réponse !
    Est ce que je ne devrais pas passer à une verison struts plus récente ?
    J'ai déjà essayé pas mal de chose

    Je remet mon struts-config.xml complet au cas ou !
    Code xml : 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
    <?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>    
            <!-- Declare un javabean de formulaire (stockage du contenu des champs dans forms) -->
     
    <!-- =========================================== Global Forward Definitions -->
        <global-forwards>
            <!-- Default forward to "Welcome" action -->
            <!-- Demonstrates using index.jsp to forward -->
            <forward
                name="welcome"
                path="/Welcome.do"/>
     
     	<forward
                name="index"
                path="/index.do"/>    
     
        </global-forwards> 
     
     
    <!--  ********************** Mapping *********************** -->   
        <action-mappings>     
                <!-- Default "Welcome" action -->
                <!-- Forwards to Welcome.jsp -->
            <action
                path="/Welcome"
                forward="/pages/Welcome.jsp" />
     
            <action
                path="/index"
                type="org.apache.struts.actions.ForwardAction"
                parameter="modele1"/>                        
     
        </action-mappings>
     
     
        <message-resources parameter="fr.edition.eni.ressources.mesMessages" />
     
     
     
     
      <plug-in className="org.apache.struts.tiles.TilesPlugin">
      <set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml" /> 
      </plug-in>
     
        </struts-config>

Discussions similaires

  1. "error is not defined"
    Par dreux dans le forum Général JavaScript
    Réponses: 1
    Dernier message: 23/11/2009, 15h22
  2. Error: JAVA_HOME is not defined correctly.
    Par saadoz dans le forum Maven
    Réponses: 5
    Dernier message: 02/03/2009, 23h33
  3. Réponses: 6
    Dernier message: 22/02/2009, 10h41
  4. Réponses: 0
    Dernier message: 05/02/2009, 12h14
  5. [VBA-W] Error! Bookmark not defined
    Par zahui_eric dans le forum VBA Word
    Réponses: 5
    Dernier message: 26/04/2007, 13h25

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