Alex_TD

Springmvc===JSON

1.js : JSON.parse(json)   Json.stringify(obj)

2.jackson:  OjbectMapper  json= new ObjectMapper()

   解决乱码:

   @RequestMapping(value="createExcel",produces="plain/text; charset=UTF-8")

                  @ResponseBody

                    String method(){   }

  <mvc:annotation-driven>
        <mvc:message-converters register-defaults="true">
            <bean class="org.springframework.http.converter.StringHttpMessageConverter">
                <constructor-arg value="UTF-8"/>
            </bean>
            <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
                <property name="objectMapper">
                    <bean class="org.springframework.http.converter.json.Jackson2ObjectMapperFactoryBean">
                        <property name="failOnEmptyBeans" value="false"/>
                    </bean>
                </property>
            </bean>
        </mvc:message-converters>
    </mvc:annotation-driven>

  

 2.fastjson    

posted on 2020-02-23 13:40  Alex_TD  阅读(107)  评论(0编辑  收藏  举报