Struts2表单验证的xml配置
位置:放在Action类的同包下
命名:
1、Action类所有方法都走校验器,ActionClassName-validation.xml,(比较容易,但不合理)
2、只校验Action中某一个方法,ActionClassName-ActionMethodName-validation.xml
注意:这里的ActionMethodName指的是Struts.xml中的<action name=" xxx" class="...">...</action>的 xxx,而不是java类的方法名
例如:
struts.xml 配置,result中必须包含有 name="input" 的配置项,表示验证未通过时展示的页面
则校验器的配置如下
校验器的配置内容如下:
jsp页面
效果展示
转载于:https://my.oschina.net/lgfei/blog/710094