Struts2框架验证--短路较验(short-circuit)
来源:互联网 发布:在淘宝买到假货怎么办 编辑:程序博客网 时间:2024/06/06 11:01
Short cuircuiting and validator flavours
A FieldValidator that gets shortcircuited will only prevent other FieldValidators for the same field
from being evaluated. Note that this "same field" behavior applies regardless of whether the or syntax
was used to declare the validation rule. By way of example, given this validation.xml file:
<validator type="required" short-circuit="true">
<param name="fieldName">bar</param>
<message>You must enter a value for bar.</message>
</validator>
<p/>
<validator type="expression">
<param name="expression">foo gt bar</param>
<message>foo must be great than bar.</message>
</validator>
both validators will be run, even if the "required" validator shortcircuits. "required" validators are
FieldValidator's and will not shortcircuit the plain ExpressionValidator because FieldValidators only
shortcircuit other checks on that same field. Since the plain Validator is not field specific, it is notshort-circuited.
上面是apache的官网的指南上获得的说明,其实意思就是说:短路适用的情况是其他要检验的字段引用了在此之前被检验的字段的时候,如果前一个检验失败,后面的相关检验就不被执行。而不是同一个字段的检验是互不相干,并不会因为在配置文件中靠前字段的检验失败,从而就不去检验其他后面的字段了。
校验器的执行顺序:
- 所有非字段校验风格的校验器优先于字段校验风格的校验器;
- 所有非字段校验风格的校验器中,排在前面的会先执行;
- 所有字段校验风格的校验器,排在前面的会先执行;
校验器短路的原则(有待确定):
- 所有非字段检验器时最优先执行的,如果某个非字段校验器校验失败了,则该字段上的所有字段校验器都不会获得校验机会;
- 非字段校验校验失败,不会阻止其他非字段校验执行;
- 如果一个字段校验器校验失败后,则该字段下且排在该校验失败后的检验器之后的其他字段校验器不会获得校验机会;
- 字段校验器永远不会阻止非字段校验器的执行!
对于复杂的校验最好写java代码进行校验!
- Struts2框架验证--短路较验(short-circuit)
- 短路求值(Short-circuit evaluation)
- Struts2验证(框架验证)
- webwork中的short-circuit问题
- HDFS Short-Circuit Local Reads
- HDFS Short-Circuit Local Reads
- HDFS Short-Circuit Local Reads
- Struts2服务器端的验证(验证框架)
- js较验框架
- struts2输入验证之短路验证
- struts2 验证继承和验证短路效应
- 详解HDFS Short Circuit Local Reads
- 详解HDFS Short Circuit Local Reads
- struts2 validate(struts2 验证框架)
- Struts2 验证框架-前台验证
- struts2的validate验证框架(1)
- Struts2 中的验证框架
- 关于struts2验证框架
- 高德地图-绘制个人历史位置路线
- 初步认识asp.net中导入excell
- loadsb指令解析
- checkstyle插件问题总结
- 导入项目出现Project has no default.properties file错误总结
- Struts2框架验证--短路较验(short-circuit)
- 关于CSDN的一些看法
- GetMyName_newInstance
- C++中指针和引用的区别
- 杨辉三角
- Qt数据库(sqlite) — 总结
- 问题小结(22)--代码实现logcat保存
- linux中的fork
- java file操作工具类