Struts2 Data Calibration method

Source: Internet
Author: User

Method:

1. Verify in the action class in the Execute () method.

Pros: The action class does not have to inherit classes from the framework.

Cons: (1) when there are multiple checksums, the code repeats, violating high cohesion and low coupling.

2. Rewrite the Validate () method in the framework Actionsupport class.

Pros: Contains the This.addfielderror () method, and once invoked, the action ends.

Cons: (1) need to inherit the Actionsupport class (intrusive) in the framework.

(2) Disadvantage of Method 1 (1).

3. Use multiple ValidateXxx () methods, XXX is the method name, and the first letter is capitalized.

Advantages: Separate multiple checks, clear structure.

Disadvantages: (1) Method 2 of the (1) disadvantage.

(2) cannot be reused.

4. Use the STRUTS2 built-in checker.

Pros: Just call, simple, fast.

Cons: (1) You need to use the specified jar package.

(2) More invasive.

Struts2 Data Calibration method

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.