SpringMVC下@ResponseBody Ajax返回json乱码java
解决办法,在spring mvc的配置文件中手工配置beanweb
<!-- 启动Spring MVC的注解功能,完成请求和注解POJO的映射 --> <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" > <property name="messageConverters"> <list> <bean class = "org.springframework.http.converter.StringHttpMessageConverter"> <property name = "supportedMediaTypes"> <list> <value>text/json;charset=UTF-8</value> </list> </property> </bean> </list> </property> </bean>
若是须要处理其余 MediaType 类型,可在list标签中加入其余value标签 spring