zoukankan      html  css  js  c++  java
  • springMVC 【@response 返回对象自动变成json并且防止乱码】 & 【配置支持实体类中的@DateTimeFormat注解】

    在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>
  • 相关阅读:
    closure
    运算符优先级
    css妙用
    BFC (块级格式化上下文)
    display:table-cell 详解
    line-height深入理解
    margin collapse
    探究 CSS 解析原理
    python入门
    spring与线程安全
  • 原文地址:https://www.cnblogs.com/flying607/p/4721582.html
Copyright © 2011-2022 走看看