validation.xml 显示错误信息 能不能每次只显示一个?

wwjxxy 2009-11-17 06:14:21
validation.xml 显示错误信息 能不能每次只显示一个?
如果能怎么操作?
...全文
70 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
wangfeis 2009-11-18
  • 打赏
  • 举报
回复
学习。。。
qustgjk 2009-11-18
  • 打赏
  • 举报
回复
是不是struts2的啊,要是的话你的意思应该是一个字段添加了多个校验器,有错误的时候错误信息都显示了,不知道是不是这个意思,要是的话在你的校验器中(除了最后一个)添加一个短路校验器就可以了,比如<field-validator type="requiredstring" short-circuit="true">
ouyangxiaokang6 2009-11-18
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 macau2008 的回复:]
参考
Java code
[Since Struts1.2.0] You can force the clientside Javascript validation to check all constraints, instead of stopping at the first error. By setting anew property, stopOnFirstError, on the Validator PlugIn tofalse.

Here's a sample configuration block that you could use in your Struts configuration file:<plug-in className="org.apache.struts.validator.ValidatorPlugIn"><set-property property="pathnames"
value="/WEB-INF/validator-rules.xml,/WEB-INF/validations.xml"/><set-property property="stopOnFirstError" value="false"/></plug-in>
将stopOnFirstError设为true即可
[/Quote]
up
码YouMe 2009-11-17
  • 打赏
  • 举报
回复
参考

[Since Struts 1.2.0] You can force the clientside Javascript validation to check all constraints, instead of stopping at the first error. By setting a new property, stopOnFirstError, on the Validator PlugIn to false.

Here's a sample configuration block that you could use in your Struts configuration file:



<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames"
value="/WEB-INF/validator-rules.xml,/WEB-INF/validations.xml"/>
<set-property property="stopOnFirstError" value="false"/>
</plug-in>


将stopOnFirstError设为true即可
zl3450341 2009-11-17
  • 打赏
  • 举报
回复
...描述太笼统了
javaors 2009-11-17
  • 打赏
  • 举报
回复
楼主的需求没说明白,他在什么情况下显示多次了?

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧