在提交之前,要进行一次表单验证,用了STRUTS2的validation。
<!-- 客户添加初始化 --> <action name="customer_init" class="cn.rf.hz.parkassist.customer.action.AddAction" method="init"> <interceptor-ref name="chain" /> <interceptor-ref name="basicStack" /> <result name="no_login">/parkassist/admin/login.jsp</result> <result name="init">/parkassist/customer/add.jsp</result> <interceptor-ref name="store"> <param name="operationMode">RETRIEVE</param> </interceptor-ref> </action> <!-- 客户添加 --> <action name="customer_add" class="cn.rf.hz.parkassist.customer.action.AddAction" method="addCustomer"> <interceptor-ref name="chain" /> <interceptor-ref name="basicStack" /> <!-- 动态设置savePath的属性值 --> <param name="savePath">upload/selfPic/</param> <result name="success" type="redirectAction">customer_search</result> <result name="failure">/parkassist/customer/add.jsp</result> <result name="no_login">/parkassist/admin/login.jsp</result> <result name="input" type="chain"> <param name="actionName">customer_init</param> <param name="namespace">/customer_action</param> </result> <interceptor-ref name="fileUpload"> <!-- 文件过滤 --> <param name="allowedTypes">image/png,image/gif,image/jpeg</param> <!-- 文件大小, 以字节为单位 --> <param name="maximumSize">1025956</param> </interceptor-ref> <interceptor-ref name="store"> <param name="operationMode">STORE</param> </interceptor-ref> <!-- 默认拦截器必须放在fileUpload之后,否则无效 --> <interceptor-ref name="defaultStack" /> </action>
http://struts.apache.org/release/2.1.x/docs/message-store-interceptor.html
<action name="submitApplication" ....> <interceptor-ref name="store"> <param name="operationMode">STORE</param> </interceptor-ref> <interceptor-ref name="defaultStack" /> <result name="input" type="redirect">applicationFailed.action</result> <result type="dispatcher">applicationSuccess.jsp</result> </action> <action name="applicationFailed" ....> <interceptor-ref name="store"> <param name="operationMode">RETRIEVE</param> </interceptor-ref> <result>applicationFailed.jsp</result> </action>
struts2的validate在使用过程中的一个问题,布布扣,bubuko.com
原文地址:http://blog.csdn.net/thisisvoa/article/details/27599603