Struts2 input verification, struts2 Verification
1. Method
① Annotations-based verification ② XML-based validation http://blog.csdn.net/furongkang/article/details/6922046 ③ manual verification a. Override validate () method B. Override validateXxx () method
2. Type: Verify all the verifications in the Action and the specified Method
3. List of validators provided by struts2 Based on XML ConfigurationThe system provides the following Checker: required (required checker, requires that the field value cannot be null) requiredstring (required string checker, requires that the field value cannot be null, And the length is greater than 0, by default, leading and trailing spaces are removed from the string.) http://blog.csdn.net/zhuangjixiang/article/details/8724611
4. Input Validation for the specified action Method Based on the XML configuration methodWhen the validation file is named ActionClassName-validation.xml, input verification is performed on all the processing methods in the action. If you only need to verify an action Method in the action, then the validation file name should be: ActionClassName-ActionName-validation.xml, where ActionName is the name of the action in struts. xml. For example, the following configurations are often used in actual applications:
<action name="user_*" class="cn.itcast.action.UserAction" method="{1}“ > <result name="success">/WEB-INF/page/message.jsp</result> <result name="input">/WEB-INF/page/addUser.jsp</result></action> UserAction has two Processing Methods: public String add () throws Exception {....} public String update () throws Exception {....} to verify the add () method, the validation file name: The UserAction-user_add-validation.xml to verify the update () method, the validation file name: UserAction-user_update-validation.xml