Visualizzazione dei risultati da 1 a 3 su 3

Discussione: Struts e Validazione

  1. #1

    Struts e Validazione

    Ciao ragazzi,
    ho inserito nel file validation.xml il seguente codice:

    Codice PHP:
    <?xml version="1.0" encoding="ISO-8859-1" ?>

    <!DOCTYPE form-validation PUBLIC
              "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1.3//EN"
              "http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd">

    <form-validation>
      <formset>

        <form name="loginformbean">
          <field property="username"
                 depends="required">
            <arg0 key="inputForm.username"/>
          </field>
          <field property="password"
                 depends="required">
            <arg0 key="inputForm.password"/>
          </field>
        </form>

      </formset>
    </form-validation>
    e nello struts-config.xml il seguente codice:

    Codice PHP:
    <form-beans>
         <
    form-bean name="loginformbean"
                   
    type="com.nota.struts.forms.LogInFormBean"/>
    </
    form-beans>
    ...    

        <
    action-mappings>
    ...
            <
    action path="/logInAction"
                
    type="com.nota.struts.LogInAction"
                
    name="loginformbean"
                
    scope="request">
                <
    forward name="dati-non-validi"
                   
    path="/nonAutenticato.do"/>
               <
    forward name="autenticazione-riuscita"
                   
    path="/autenticato.do"/>
            </
    action>-->
        </
    action-mappings>
    ... 
    Ma ricevo all'avvio il seguente errore:

    GRAVE: Parse Error at line 35 column 23: The content of element type "action-mappings" must match "(action)*".
    org.xml.sax.SAXParseException: The content of element type "action-mappings" must match "(action)*".


    Secondo voi, perchè?

  2. #2
    Utente di HTML.it
    Registrato dal
    Sep 2006
    Messaggi
    42
    Ciao Magnus,
    prova con questo:

    <?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="loginformbean"
    type="com.nota.struts.forms.LogInFormBean"/>
    </form-beans>

    <global-exceptions>

    </global-exceptions>

    <global-forwards>
    <forward name="welcome" path="/Welcome.do"/>
    </global-forwards>

    <action-mappings>
    ...
    <action path="/logInAction"
    type="com.nota.struts.LogInAction"
    name="loginformbean"
    scope="request">
    <forward name="dati-non-validi"
    path="/nonAutenticato.do"/>
    <forward name="autenticazione-riuscita"
    path="/autenticato.do"/>
    </action>-->
    </action-mappings>


    <controller processorClass="org.apache.struts.tiles.TilesReque stProcessor"/>

    <message-resources parameter="com/myapp/struts/ApplicationResource"/>


    <!--
    This plugin initialize Tiles definition factory. This later can takes some
    parameters explained here after. The plugin first read parameters from
    web.xml, thenoverload them with parameters defined here. All parameters
    are optional.
    The plugin should be declared in each struts-config file.
    - definitions-config: (optional)
    Specify configuration file names. There can be several comma
    separated file names (default: ?? )
    - moduleAware: (optional - struts1.1)
    Specify if the Tiles definition factory is module aware. If true
    (default), there will be one factory for each Struts module.
    If false, there will be one common factory for all module. In this
    later case, it is still needed to declare one plugin per module.
    The factory will be initialized with parameters found in the first
    initialized plugin (generally the one associated with the default
    module).
    true : One factory per module. (default)
    false : one single shared factory for all modules
    - definitions-parser-validate: (optional)
    Specify if xml parser should validate the Tiles configuration file.
    true : validate. DTD should be specified in file header (default)
    false : no validation

    Paths found in Tiles definitions are relative to the main context.
    -->
    <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" />
    </plug-in>


    <plug-in className="org.apache.struts.validator.ValidatorPl ugIn">
    <set-property
    property="pathnames"
    value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
    </plug-in>

    </struts-config>


    Mancano tutte le intestazioni del file xml e le opzioni necessarie per far funzionare il framework.

    Carmine Montella

  3. #3
    Originariamente inviato da Beck74
    Ciao Magnus,
    prova con questo:

    <?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="loginformbean"
    type="com.nota.struts.forms.LogInFormBean"/>
    </form-beans>

    <global-exceptions>

    </global-exceptions>

    <global-forwards>
    <forward name="welcome" path="/Welcome.do"/>
    </global-forwards>

    <action-mappings>
    ...
    <action path="/logInAction"
    type="com.nota.struts.LogInAction"
    name="loginformbean"
    scope="request">
    <forward name="dati-non-validi"
    path="/nonAutenticato.do"/>
    <forward name="autenticazione-riuscita"
    path="/autenticato.do"/>
    </action>-->
    </action-mappings>


    <controller processorClass="org.apache.struts.tiles.TilesReque stProcessor"/>

    <message-resources parameter="com/myapp/struts/ApplicationResource"/>


    <!--
    This plugin initialize Tiles definition factory. This later can takes some
    parameters explained here after. The plugin first read parameters from
    web.xml, thenoverload them with parameters defined here. All parameters
    are optional.
    The plugin should be declared in each struts-config file.
    - definitions-config: (optional)
    Specify configuration file names. There can be several comma
    separated file names (default: ?? )
    - moduleAware: (optional - struts1.1)
    Specify if the Tiles definition factory is module aware. If true
    (default), there will be one factory for each Struts module.
    If false, there will be one common factory for all module. In this
    later case, it is still needed to declare one plugin per module.
    The factory will be initialized with parameters found in the first
    initialized plugin (generally the one associated with the default
    module).
    true : One factory per module. (default)
    false : one single shared factory for all modules
    - definitions-parser-validate: (optional)
    Specify if xml parser should validate the Tiles configuration file.
    true : validate. DTD should be specified in file header (default)
    false : no validation

    Paths found in Tiles definitions are relative to the main context.
    -->
    <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" />
    </plug-in>


    <plug-in className="org.apache.struts.validator.ValidatorPl ugIn">
    <set-property
    property="pathnames"
    value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
    </plug-in>

    </struts-config>


    Mancano tutte le intestazioni del file xml e le opzioni necessarie per far funzionare il framework.

    Carmine Montella
    No, no ci sono. Solo che non le ho riportate.

    Ho riportato solo quei pezzi perchè pensavo che in quel punto ci fosse un errore.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.