The file cannot be validated as the XML definition 异常解决办法
来源:互联网 发布:centos wget 命令 编辑:程序博客网 时间:2024/05/22 00:41
在struts2中配置验证框架时,回报上面的错误。这时候,要学会读懂英文意思。文件不能被验证的XML定义。下面看完整的错误提示。
The file cannot be validated as the XML definition "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd" that is specified as describing the syntax of the file cannot be located.
马上到xwork核心文件中找xwork-validator-1.0.2.dtd的文件的约定规则和自己写的意义对应。
<validators> <field name="user.name"> <field-validator type="requiredstring"> <param name="trim">true</param> <message>用户名不能为空</message> </field-validator> <field-validator type="stringlength"> <param name="maxLength">10</param> <param name="minLength">6</param> <message>用户名长度必须在${minLength}和${maxLength}之间</message> </field-validator> </field> </validators> <validators> <field name="user.pwd"> <field-validator type="requiredstring"> <param name="trim">true</param> <message>密码不能为空</message> </field-validator> <field-validator type="stringlength"> <param name="minLength">6</param> <message>长度必须大于${minLength}</message> </field-validator> </field> <field name="repwd"> <field-validator type="requiredstring"> <param name="trim">true</param> <message>确认密码不能为空</message> </field-validator> <field-validator type="fieldexpression"> <param name="expression">user.pwd==repwd</param> <message>密码和确认密码必须相等</message> </field-validator> </field> </validators>
对比发现 是根节点,我多写了。只保留一个就好了。
完整jsp页面代码:
<s:fielderror/> <s:form action="reg" method="post"> <s:textfield name="user.name" label="用户名" /> <s:password name="user.pwd" label="密码" /> <s:password name="repwd" label="确认密码" /> <s:textfield name="user.telephone" label="电话" /> <s:textfield name="user.username" label="用户姓名" /> <s:submit value="立即注册" /> </s:form>
配置文件,配置文件要用请求文件放在一起。命名要注意,如果action命名:RegisterAction,配置文件为:RegisterAction-validation.xml
<?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" > <validators> <field name="user.name"> <field-validator type="requiredstring"> <param name="trim">true</param> <message>用户名不能为空</message> </field-validator> <field-validator type="stringlength"> <param name="maxLength">10</param> <param name="minLength">6</param> <message>用户名长度必须在${minLength}和${maxLength}之间</message> </field-validator> </field> <field name="user.pwd"> <field-validator type="requiredstring"> <param name="trim">true</param> <message>密码不能为空</message> </field-validator> <field-validator type="stringlength"> <param name="minLength">6</param> <message>长度必须大于${minLength}</message> </field-validator> </field> <field name="repwd"> <field-validator type="requiredstring"> <param name="trim">true</param> <message>确认密码不能为空</message> </field-validator> <field-validator type="fieldexpression"> <param name="expression">user.pwd==repwd</param> <message>密码和确认密码必须相等</message> </field-validator> </field> <field name="user.telephone"> <field-validator type="requiredstring"> <param name="trim">true</param> <message>电话号码不能为空</message> </field-validator> <field-validator type="regex"> <param name=" regex ">^(\d{3,4}-){0,1}(\d{7,8}))$</param> <message>电话格式不正确</message> </field-validator> </field> <field name="user.username"> <field-validator type="requiredstring"> <param name="trim">true</param> <message>用户姓名不能为空</message> </field-validator> <field-validator type="stringlength"> <param name="maxLength">10</param> <param name="minLength">2</param> <message>用户名长度必须在${minLength}和${maxLength}之间</message> </field-validator> </field> </validators>
acrion
package actions; import com.opensymphony.xwork2.ActionSupport;import entity.User;public class RegisterAction extends ActionSupport { private User user; private String repwd; public User getUser() { return user; } public void setUser(User user) { this.user = user; } public String getRepwd() { return repwd; } public void setRepwd(String repwd) { this.repwd = repwd; } public String execute(){ return SUCCESS; } }
0 0
- The file cannot be validated as the XML definition 异常解决办法
- The file cannot be validated as the XML definition...
- mybatis的xml文件没有提示,出现the file cannot be validated as the XML definition.....
- Eclipse log4j.xml – log4j.dtd cannot be validated as the XML definition
- The file cannot be validated as there was a connection problem. struts-config.xml
- The file cannot be validated as the host "struts.apache.org" is currently unreachable.
- struts问题the file cannot be validated as the host "struts.apache.org" is currently unreachable
- 在ibatis的提示出错:“The file cannot be validated as there was a connection problem. ”
- because the project file cannot be parsed.解决办法
- struts2 The Struts dispatcher cannot be found异常解决办法
- sql server 2000 安装错误:the specified file cannot be opened as read-only .ensure the source file is pre
- The action name cannot be the same as the action suffix [Action]遇到此有关问题的解决办法
- Caused by: Axis2:The services.xml file cannot be found for the service
- cannot be opened because the project file cannot be parsed
- cannot be opened because the project file cannot be parsed
- Xcode 打开SVN更新后的工程提示,cannot be opened because the project file cannot be parsed解决办法
- “cannot access the ClassView information file, ClassView information will not be available.”的解决办法
- 解决【the project file'xxxx'cannot be opened.the project ...】
- android之WindowManager
- 【多线程】java.util.concurrent.Exchanger应用范例与原理浅析
- window平台安装 MongoDB
- 百度面试之第一回合
- HDU 5779 Tower Defence
- The file cannot be validated as the XML definition 异常解决办法
- 【leetcode76】Intersection of Two Arrays II
- 架构漫谈(五):什么是软件
- 2016多校训练Contest4: 1005 Lucky7 hdu5768
- 多线程--线程同步
- 用chrome调试Android程序
- 从头学android_LocationManager的使用
- 工作三周总结
- Zookeeper报错Will not attempt to authenticate using SASL解决办法