Spring MVC (iii) Data conversion, formatting, validation

Source: Internet
Author: User

Data conversion, formatting, validation

Data binding mechanism

Data type conversions

The lower version of spring supports only the standard PropertyEditor type system, but the PropertyEditor has the following drawbacks:
Conversions that can be used only for strings and Java objects, not for conversions between any of the two Java types;
The context information (such as annotations, the structure of the host class, etc.) is not sensitive to the source object and the target object, which cannot be used to implement advanced conversion logic when type conversion occurs.
In view of this, spring 3.0 adds a common type conversion module to the core model, and Conversionservice is the core interface of the spring type conversion architecture.
Spring 3.0 supports both PropertyEditor and Conversionservice for type conversion, working with a type conversion system in Bean configuration, Spring MVC processing method entry bindings.

For simple type conversions, it is still recommended to use PropertyEditor. According to the PropertyEditor protocol, the Bean class will automatically find out if the same class package exists <beanname>editor.class, if there is an editor that uses it as a bean.

<bean id= "Expiremanager"
class= "Com.book.core.cache.expire.SimpleCacheLogicExpireManager" >
<property name= "Cachespacelist" >
<list>
<value>combookspace:com/combook/**</value>
<value>bookspace:com/book/**:100</value>
<value>companyspace:com/company/**</value>
</list>
</property>
</bean>

Spring MVC (iii) Data conversion, formatting, 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.