由于万恶的Spring MVC 默认返回编码 是 ISO-8859-1, 使用如下配置, 可以将编码专为UTF-8,

    <bean
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<bean
class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<bean class="org.springframework.http.MediaType">
<constructor-arg index="0" value="text" />
<constructor-arg index="1" value="plain" />
<constructor-arg index="2" value="UTF-8" />
</bean>
</list>
</property>
</bean>
</list>
</property>
</bean>

但是, 如果使用 POST 请求的时候 后台可能会报

org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation

因为请求的头信息中 可能请求返回的不是 text/plain;charset=UTF8  这种格式,需要吧request 的 Accept 设置为 text/plain;charset=UTF8.

最新文章

  1. WCF 框架运行时类图
  2. oracle表连接——处理连接过程中另外一张表没有相关数据不显示问题
  3. mac点滴
  4. CI邮箱中SMTP的一些端口
  5. android之location 根据接口获取经纬度信息
  6. PHP入门基础(一)——标记风格、注释、表单获取、字符串类型、变量解析
  7. linux下手动安装apache详解
  8. Kill命令模拟1
  9. SQL学习之汇总数据之聚集函数
  10. Linux驱动技术(四) _异步通知技术
  11. html5中的meta标签
  12. Mac: Android studio+VirtualBox+Genymotion
  13. Oracle忘记密码如何重
  14. Java中的String,StringBuilder,StringBuffer三者的区别
  15. 今天终于想明白为什么java包要倒着写
  16. P5238 整数校验器
  17. ROW_NUMBER() OVER(PARTITION BY COLUMN ORDER BY COLUMN)
  18. Python *Mix_w7
  19. Jboss7或者wildfly部署war包的问题
  20. 判断用户访问方式为pc or Phone

热门文章

  1. 一次搞懂 Assets Pipeline 转载自http://gogojimmy.net/2012/07/03/understand-assets-pipline/
  2. 把复选框变成单选框(prop,attr的区别)
  3. 上架app被拒原因总结
  4. 在Linux中创建静态库和动态库 (转)
  5. mapper分页排序指定字段查询模板
  6. 《UNIX环境高级编程》笔记--文件共享
  7. Spring 拦截器实现事物
  8. Nutch 二次开发之parse正文内容
  9. libevent入门
  10. java结构与算法之冒泡排序