<bean name="/createAddr.do" class="cn.richinfo.mail.webmail.web.action.AddrCreateFormAction">
<property name="groupService" ref="addrGroupService"/>
<property name="commandName" value="addr" />
<property name="formView" value="addAddr"/>
<property name="validator" ref="beanValidator"/>
<property name="successView" value="redirect:addr.do"/>
</bean>
在配置一个SimpleFormController时,commandName 验证的表单名, 这个名字会被common validator使用;
否则抛出异常:Neither BindingResult nor plain target object for bean name 'addr' available as request attribute
验证框架的validation_zh_CN.properties和多语言资源文件要放在WEB-INF/classes目录下,这是什么原因,可不可以放到别的目录?
<form name="addr">
<field property="serialId" depends="maxlength,required">
<arg0 key="addr.serialId.displayName" />
<arg1 name="maxlength" key="${var:maxlength}" resource="false" />
<var>
<var-name>maxlength</var-name>
<var-value>10</var-value>
</var>
</field>
<field property="addrFirstName" depends="maxlength,required">
<arg0 key="addr.addrFirstName.displayName" />
<arg1 name="maxlength" key="${var:maxlength}" resource="false" />
<var>
<var-name>maxlength</var-name>
<var-value>10</var-value>
</var>
</field>
</form>
form name="addr"这里的name是表单的name,如:<form name="addr" action="xxxxxx">
<arg0 key="addr.serialId.displayName" />arg0是该字段的显示名,用于验证失败时显示提示信息,key是定义在messageResourece中的消息的key,如:我的validation_zh_CN.properties
errors.required={0}不能为空.
errors.maxlength={0}不能超过{1}个字符
addr.serialId.displayName=通讯录ID
出错提示会这样显示:通讯录ID不能为空