Custom converter implementation Converter Interface
//String It's the original type ,Date Is the target type to convert public class CustomDateConverter implements
Converter<String, Date> { @Override public Date convert(String source) { try {
return new SimpleDateFormat("yyyy-MM-dd").parse(source); } catch (Exception e)
{ e.printStackTrace(); } return null; } }
Configuration converter

Configuration mode 1 : For not using mvc Driven
<!-- Annotation adapter --> <bean
class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
<property name="webBindingInitializer" ref="customBinder"></property> </bean>
<!-- custom webBinder --> <bean id="customBinder"
class="org.springframework.web.bind.support.ConfigurableWebBindingInitializer">
<property name="conversionService" ref="conversionService" /> </bean> <!--
conversionService --> <bean id="conversionService"
class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
<!-- converter --> <property name="converters"> <list> <bean
class="cn.itcast.ssm.controller.converter.CustomDateConverter"/> </list>
</property> </bean>
Configuration mode 2 : For use mvc Driven
<mvc:annotation-driven conversion-service="conversionService">
</mvc:annotation-driven> <!-- conversionService --> <bean
id="conversionService"
class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
<!-- converter --> <property name="converters"> <list> <bean
class="cn.itcast.ssm.controller.converter.CustomDateConverter"/> </list>
</property> </bean>
 

Technology
©2020 ioDraw All rights reserved
Java realization PDF Online preview ( Four methods ) Android Development — Display food information according to customer budget spark.sql.shuffle.partitions and spark.default.parallelism The difference between Big data environment --- data warehouse (hive+mysql+hadoop) The construction of Children programming children's learning route What do you do in Shanghai to make money fast ? this 10 You can have a try ! Advanced programmer - Deep understanding of data structure After the outbreak Which programming has a bright future 2020 Nobel Prize in physiology or medicine announced Trump's "VIP therapy ": Is receiving a drug treatment that has not yet been approved