SPRINGMVC Learning 11-validation Calibration

Source: Internet
Author: User

1. Understanding of the test

Projects, often use more front-end checks, such as the page JS check. For higher security requirements, it is recommended to validate on the service side.

Service-side check:

Control layer Conroller: Verifies the legality of the parameters requested by the page. Conroller checksum on the server-side control layer, with no distinction between client types (browser, mobile client, remote Call)

Business Layer Service (use more): Mainly check the key business parameters, limited to the parameters used in the service interface.

Persistence Layer DAO: It is generally not verified.

2.SPRINGMVC Calibration Requirements

SPRINGMVC uses Hibernate's check frame validation (and hibernate has no relationship).

Calibration ideas:

The parameter of the page submission request, which is requested into the Controller method, is verified with validation. If the checksum error occurs, the error message is displayed to the page.

Specific requirements:

Product modification, add check (check the product name length, the production date of the non-null check), if the check error, the Product modification page displays an error message.

3. Environmental preparedness

4. Configuring the Validator

Configuring in Springmvc.xml

5. Officer the detector into the processor adapter

6. Add a validation rule to the Pojo

7.customvalidationmessages.properties

8. Capturing checksum error messages

9. Display the check error message on the page

SPRINGMVC Learning 11-validation Calibration

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.