什么bug啊,求学习
--------------------编程问答--------------------
我用xml+注解组合配置刚搞定了日期转换的问题,给楼主分享一下:
xml配置:
<mvc:annotation-driven conversion-service="conversionService"/>
注解配置(从spring.io上抄的)
@Configuration
public class AppConfig {
public AppConfig() {
}
@Bean
public FormattingConversionService conversionService() {
// Use the DefaultFormattingConversionService but do not register defaults
DefaultFormattingConversionService conversionService = new DefaultFormattingConversionService(false);
// Ensure @NumberFormat is still supported
conversionService.addFormatterForFieldAnnotation(new NumberFormatAnnotationFormatterFactory());
// Register date conversion with a specific global format
DateFormatterRegistrar registrar = new DateFormatterRegistrar();
registrar.setFormatter(new DateFormatter("yyyy-MM-dd"));
registrar.registerFormatters(conversionService);