struts2.0验证框架出现Document root element "validators", must match DOCTYPE root "stru

: Document root element "validators", must match DOCTYPE root "struts". at (null:5:13)
org.xml.sax.SAXParseException: Document root element "validators", must match DOCTYPE root "struts".
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318)
    at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.rootElementSpecified(XMLDTDValidator.java:1621)
    at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleStartElement(XMLDTDValidator.java:1900)
    at
2011-5-1 20:58:59 com.opensymphony.xwork2.validator.AnnotationActionValidatorManager loadFile
严重: Caught exception while loading file org/action/StrutsAction-validation.xml
Document root element "validators", must match DOCTYPE root "struts". - file:///D:/Program%20Files/Java/tools/apache-tomcat-6.0.16/bin/org/action/StrutsAction-validation.xml:5:13
    at com.opensymphony.xwork2.util.DomHelper.parse(DomHelper.java:123)
    at com.opensymphony.xwork2.validator.ValidatorFileParser.parseActionValidatorConfigs(ValidatorFileParser.java:54)
    at com.opensymphony.xwork2.validator.AnnotationActionValidatorManager.loadFile(AnnotationActionValidatorManager.java:361)
    at

 

 

     错误原因:验证框架配置文件标签错误原来为:
     <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">
   
    应为:<?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE validators PUBLIC
          "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
          "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">

现总结验证框架经常注意问题

校验文件没有问题:

1.校验Action必须继承ActionSupport

2.校验文件命名

Action类名-validation.xml

Action类名-Action请求名-validation.xml

3.校验文件必须同Action类在同一目录下。

 

 

你可能感兴趣的:(java,apache,框架,struts,sun)