SpringMVC @ResponseBody Ajax返回json亂碼

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

相關文章
相關標籤/搜索