Struts2 Review (3) Verification Summary

Source: Internet
Author: User

1. Struts2 framework validation execution sequence: 1) First, the validation framework (xml file) is executed)
2) perform the validation method of the custom method (validateMyExecute)
3) execute the validate method 2. Input Validation of the custom method in Action. For the custom method specified by the method attribute of action, the corresponding custom input verification method is validateMyExecute (assume that the custom method is myExecute ). The underlying layer is called through reflection.
Note: When a custom execute method is specified in the Action, the input verification method corresponding to the custom execute method is executed first, and then the validate method is executed, after the execution is completed, if any errors occur, the custom task will not be executed again.
The xecute method redirects the process to the page corresponding to the input name.
3. Custom Field-level error message 1) create a new properties file named by Action, as shown in
RegisterAction. properties.
2) Specify the error message for each error field in the property file.
Invalid. fieldvalue. birthday = birthday invalid !!
4. Struts2 Verification Framework (a valid xml file ). Specifically, it can be divided into the field priority validator and the priority validator.
5. The naming rules for international resource files are package _ language name_country name,
For example, package_zh_CN, package_en_US
NOTE: For the result configuration of the struts. xml file, the local configuration is better than the global configuration.

We can either define exceptions and results in actions, or define global exceptions and results. Local exceptions are always better than global ones. If they are defined as global ones, they can be shared by all actions, local exceptions and results can only be exclusive to the current Action and cannot be shared by other actions.


You are welcome to join us in the discussion and study!

Collect it by yourself!

Record and share, let you grow together! Welcome to my other blog; my blog address: http://blog.csdn.net/caicongyang





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.