SPRINGMVC configuration file
<!-- Instead of org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping and ORG.SPRINGFRAMEWORK.WEB.SERVLET.MVC . method.annotation.requestmappinghandleradapter --><mvc:annotation-driven conversion-service= " Conversionservice "></mvc:annotation-driven><!-- Custom parameter binding --><bean id=" Conversionservice " class=" Org.springframework.format.support.FormattingConversionServiceFactoryBean "> <property name= "Converters" > <list> <!-- Date type conversions --> <bean class= "converter. Customdateconverter "></bean> </list> </property></bean>
org.springframework.format.support.FormattingConversionServiceFactoryBean
Spring provides a converter external interface that can inject its own written converter converter
A custom parameter binding component needs to be injected into the processor adapter, and this example interfaces in the annotation driver
Conversion-service= "Conversionservice"
Custom Date Converters
Package converter;import java.text.parseexception;import java.text.simpledateformat;import java.util.Date;import org.springframework.core.convert.converter.Converter;public class customdateconverter implements converter<string, date> { @ Override public date convert (String source) { The //implementation converts a date string into a date type, formatted as a yyyy-mm-dd hh:mm:ss simpledateformat simpledateformat = new simpledateformat ("Yyyy-MM-dd HH: Mm:ss "); try { return simpledateformat.parse (source); } catch ( Parseexception e) { e.printstacktrace (); } return null; }}
This article is from the "bit accumulation" blog, please be sure to keep this source http://tianxingzhe.blog.51cto.com/3390077/1729314
Spring 3.2 Custom Parameter binding--date format converter