解決ResponseBody響應中文亂碼問題


第一種方法:
<!--配置注解驅動-->
<mvc:annotation-driven>
<!--消息轉換器,解決ResponseBody響應中文亂碼-->
<mvc:message-converters>
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes" value="text/html;charset=UTF-8"/>
<property name="defaultCharset" value="UTF-8"/>
</bean>
</mvc:message-converters>
</mvc:annotation-driven>
在spring-mvc中的配置文件中配置一個字符串消息轉換器即可。

第二種方法:
@RequestMapping(value = "/login",method = RequestMethod.POST, produces = "application/json;charset=utf-8")


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM