Struts2 input verification, struts2 Verification

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.