在springmvc的配置文件中加上这一段即可
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" > <!-- 本文关键内容--> <property name="messageConverters"> <list> <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter" > <property name="supportedMediaTypes"> <value>text/html;charset=UTF-8</value> </property> </bean> </list> </property> <!-- 支持@DateTimeFormat(pattern="yyyy-MM-dd")等注解 2015年7月31日11:07:03 liuyx--> <property name="webBindingInitializer"> <bean class="org.springframework.web.bind.support.ConfigurableWebBindingInitializer"> <property name="conversionService"> <bean class="org.springframework.format.support.FormattingConversionServiceFactoryBean"></bean> </property> </bean> </property> </bean>
时间: 2024-11-23 13:19:10