Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 编程语言 > Java > 使用Struts-Validator常见错误[经典]
【标  题】:使用Struts-Validator常见错误[经典]
【关键字】:Struts-Validator
【来  源】:http://blog.csdn.net/patriotlml/archive/2006/05/31/766353.aspx

使用Struts-Validator常见错误[经典]

Your Ad Here 最近一段时间忙着用struts-Validator作毕业设计,遇到了一些问题,老是出错,从网上找到这篇文章,真是经典,赶忙收藏起来,以备来日大用。
 

Make sure you have the following:
 1) ApplicationResources.properties file with keys/values for standard validators (at least - errors.required)
 2) struts-config.xml file should contain the reference to this resource file for message-resources node.
 3) struts-config plug-in node should contain validator Plugin className="org.apache.struts.validator.ValidatorPlugIn"
 4) The plugin should have set-property with name pathnames that corresponds to validator files (such as /WEB-INF/validator-rules.xml and /WEB-INF/validation.xml)
 5) Action Validation vs. Form Validation. Alternative solutions:
 Solution A:
 - Form Validation: validation.xml should contain form with name
 that corresponds to form-bean name in struts-config.
 - Form Bean or its Parent should inherit
 org.apache.struts.validator.ValidatorForm class
 Solution B (povides more flexibility):-
 - Form Validation: validation.xml should contain form with name that corresponds to action’s path name in struts-config.
 - Form Bean or its Parent should inherit org. apache.struts.validator.ValidatorActionForm.

 6) The form should have a field with property that corresponds to field name we want to validate. Nested properties are okay.
 7) This field should have a 'depends' attribute that corresponds to the validator name mentioned in /WEB-INF/validator-rules.xml (i.e. 'required')
 8) This field should have an arg0 node with attribute key that corresponds to existing key in application resource file
 9) in action-mapping: 'input' attribute of action should reference to jsp page with validated form and validate should be set to true.
 12) jsp page should contains <html:errors /> (or its substitute)

 File Compatibility:
 1) Make sure the validation-rules.xml and commons-validator.jar match.
 The xml version and jar’s implementation version need to be compatible
 2) Make sure your struts.jar version is compatible with the commons-validator.jar
 3 ) Compabitly issues will usually result in validation not working and no errors or warnings to trace the problem. To avoid issues, simply do not attempt to reuse other's validation.xml, validation-rules.xml, and commons-validator.jar files. Only use files that are packaged with your struts distribution zip/tar file.

接口与多重继承:【上一篇】
Hibernate使用总结:【下一篇】
【相关文章】
没有相关文章
【随机文章】
  • MATLAB关系操作符
  • [一些网站的WEB SERVER OS]
  • 请教:关于windows ce 2.1的开发环境[代友发问]
  • 蠕虫技术小结
  • [Design Pattern] The Decorator Pattern
  • 无线信号放大器WSB24
  • JavaScript的属性实现
  • 利用.NET的Reflection增强对象工厂的扩展性
  • [新功能]新闻管理
  • Director Lingo 语言入门(3)
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 bbb软讯网络 All Rigths Reserved.