0

我收到错误

元素类型“formset”的内容必须匹配“(constant*,form+)”

当我执行我的 struts 应用程序时,它会给出如下错误:

2013-09-27 15:22:35  ERROR org.apache.commons.digester.Digester - Parse Error at line 203 column 15: The content of element type "formset" must match "(constant*,form+)".
org.xml.sax.SAXParseException; lineNumber: 203; columnNumber: 15; The content of element type "formset" must match "(constant*,form+)".
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleEndElement(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.endElement(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    at org.apache.commons.digester.Digester.parse(Digester.java:1666)
    at org.apache.commons.validator.ValidatorResources.<init>(ValidatorResources.java:159)
    at org.apache.struts.validator.ValidatorPlugIn.initResources(ValidatorPlugIn.java:237)
    at org.apache.struts.validator.ValidatorPlugIn.init(ValidatorPlugIn.java:162)
    at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServlet.java:869)
    at org.apache.struts.action.ActionServlet.init(ActionServlet.java:336)
    at javax.servlet.GenericServlet.init(GenericServlet.java:160)
    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1266)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1185)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1080)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5001)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5289)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1525)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1515)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

我已经编写了validation.xml文件,如下所示。

<?xml version="1.0" encoding="UTF-8" ?>

<!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>   
    <global> 
    </global> 
    <formset>        
        <form name="logonForm">
            <field
                property="username"
                depends="registerrequired">
                <arg key="logonForm.username"/>
            </field>

        </form>

      <form name="attachdynamicLookupForm">
            <field 
                property="theFile"
                depends="registerrequired">
                <arg key="attachdynamicLookupForm.to"/>
            </field>

        </form>


        <form name="UserFormBean">
            <field 
                property="username"
                depends="required">
                <arg key="userbean.username"/>
            </field>
            <field
                property="firstname"
                depends="required">
                <arg key="userbean.firstname"/>
            </field>
            <field
                property="lastname"
                depends="required">
                <arg key="userbean.lastname"/>
            </field>
            <field
                property="address"
                depends="required">
                <arg key="userbean.address"/>
            </field>
            <field
                property="city"
                depends="required">
                <arg key="userbean.city"/>
            </field>
            <field
                property="postcode"
                depends="required,mask">
                <msg name="mask" key="userbean.postcode.mask"/>
                <arg key="userbean.postcode"/>
                <var>
                    <var-name>mask</var-name>
                    <var-value>^[0-9a-zA-Z]{6}</var-value>
                </var>
            </field>
            <field
                property="mobileno"
                depends="required,mask">
                <msg name="mask" key="userbean.mobile.mask"/>    
                <arg key="userbean.mobileno"/>
                <var>
                    <var-name>mask</var-name>
                    <var-value>^[0-9]{12}</var-value>
                </var>
            </field>
            <field
                property="email"
                depends="required,email">
                <arg key="userbean.email"/>
            </field>
        </form>

        <form name="DynaUpdateContactForm">
            <field
                property="contactName"
                depends="registerrequired">
                <arg key="dynaupdatecontact.contactname"/>
            </field>
            <field
                property="contactNumber"
                depends="registerrequired,phone">
                <arg key="dynaupdatecontact.contactnumber"/>
            </field>
        </form>
           <!--    resetpassword form   -->
        <form name="DynaResetPassActionForm">
            <field
                property="username"
                depends="registerrequired">
                <arg key="resetpass.username"/>
            </field>
            <field
                property="newpass"
                depends="registerrequired,mask">
                <arg key="resetpass.newpass"/>
                <var>
                    <var-name>mask</var-name>
                    <var-value>^[0-9a-zA-Z]*$</var-value>
                </var>
            </field>
            <field
                property="conpass"
                depends="registerrequired,mask">
                <arg key="resetpass.conpass"/>
                <var>
                    <var-name>mask</var-name>
                    <var-value>^[0-9a-zA-Z]*$</var-value>
                </var>
            </field>
        </form>

        <!--    changepassword form   -->
        <form name="DynaChangePassActionForm">
            <field
                property="oldpassword"
                depends="registerrequired">
                <arg key="changepass.oldpass"/>
            </field>
            <field
                property="newpass"
                depends="registerrequired,mask">
                <arg key="changepass.newpass"/>
                <var>
                    <var-name>mask</var-name>
                    <var-value>^[0-9a-zA-Z]*$</var-value>
                </var>
            </field>
            <field
                property="conpass"
                depends="registerrequired,mask">
                <arg key="changepass.conpass"/>
                <var>
                    <var-name>mask</var-name>
                    <var-value>^[0-9a-zA-Z]*$</var-value>
                </var>
            </field>
        </form>

        <form name="DynaUpdateSenderNameActionForm">
            <field
                property="newsendername"
                depends="registerrequired">
                <arg key="dynaupdatesendername.newsender"/>
            </field>

        </form>

        ///////////////////
        <form name="DynaSMSRequestActionForm">
            <field
                property="req"
                depends="registerrequired,mask">
                <arg key="smsrequest.request"/>
                <var>
                    <var-name>mask</var-name>
                    <var-value>^[ 0-9]+$</var-value>
                </var>
            </field>    
        </form>

    </formset> 

    <!-- An example formset for another locale -->
    <formset language="fr">

        <constant>
            <constant-name>postalCode</constant-name>
            <constant-value>^[0-9a-zA-Z]*$</constant-value>
        </constant>

        <!-- An example form -->
        <form name="logonForm">
            <field
                property="username"
                depends="required">
                <arg key="logonForm.username"/>
            </field>
            <field
                property="password"
                depends="required,mask">
                <arg key="logonForm.password"/>
                <var>
                    <var-name>mask</var-name>
                    <var-value>^[0-9a-zA-Z]*$</var-value>
                </var>
            </field>
        </form>

    </formset>

</form-validation>
4

3 回答 3

1

您的路径中可能有另一个文件与验证器的命名标准匹配。

于 2013-10-02T07:41:45.780 回答
1

很可能你因为你的“////”而遇到了麻烦

///////////////////
    <form name="DynaSMSRequestActionForm">

您应该从代码中删除这些并重试。希望这可以帮助。

于 2013-12-31T06:43:57.297 回答
0

<var-jstype>如果您看到下面的示例,请将其与您错过的 xml 文件进行比较<var>

请试试这个。

<field property="id" depends="intRange">
            <arg key="id" resource="false" />
            <arg key="${var:min}" resource="false" />
            <arg key="${var:max}" resource="false" />

            <var>
              <var-name>min</var-name>
              <var-value>10</var-value>
              <var-jstype></var-jstype>
            </var>

        </field>
于 2016-06-08T16:34:55.843 回答