SPRINGMVC data conversion, formatting, and data validation

Source: Internet
Author: User

Springmvc the information in the request is converted in a certain way and bound to the parameters of the request method, depending on the signature of the request method. SPRINGMVC also does a lot of other work during the time the request message arrives to actually call the processing method, including request information transformation, data conversion, data formatting, and data validation.

First, data binding

The core part of data binding is that the DATABINDER,SPRINGMVC framework passes the ServletRequest object and the Parameter object instance of the processing method to DataBinder, DataBinder invokes the Conversionservice component assembled in the Springweb context for data type conversion, data formatting, and populating the messages in the ServletRequest into the Parameter object. The validator component is then called to perform data validation on the parameter object that is already bound to the request message data, and eventually generates a data-bound result Bindingresult object. The Bindingresult contains a parameter object that has already completed data binding, a corresponding checksum error object, SPRINGMVC extracting the Parameter object from the Bindingresult and validating the error object, assigning them to the corresponding parameters of the processing method.

Second, data conversion

In the Java language, a propertyeditor interface is provided in the Java.beans package for data conversion. The core function of PropertyEditor is to use a string as a Java object to construct a Java object based on the interface's input or configuration string in the configuration file.

Third, the format of data

Spring uses the converter converter to convert a source type object to a target type object, and the spring converter does not assume input and output information formatting.

Four, data verification

A robust application must keep these illegal inputs out of the app and prevent some illegal input from being prevented from entering the system outside of the application, so that it can be guaranteed to be unaffected.

SPRINGMVC data conversion, formatting, and data validation

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.