关闭

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

标签: struts框架actionencodingexceptionfile
903人阅读 评论(0) 收藏 举报
分类:

转自http://moon-yang85-gmail-com.iteye.com/blog/1025917

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类在同一目录下。

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:126619次
    • 积分:1516
    • 等级:
    • 排名:千里之外
    • 原创:15篇
    • 转载:61篇
    • 译文:0篇
    • 评论:18条
    最新评论