解决方法一:@RequestMapping(value="/getphone",produces = "text/plain;charset=utf-8")

/**输入手机号码后判断手机号是否存在*/
@RequestMapping(value="/getphone",produces = "text/plain;charset=utf-8")
@ResponseBody
public String getphone(String phone,HttpSession session){
Users u=service.selectPhoneService(phone);
if(u==null){//如果为空,则需要注册
String str="请您先注册,再登录。";
session.setAttribute("str", str);
return "请您先注册,再登录。";
}
return "true";
}

解决方法二,在spring-mvc.xml中添加:

<!-- 处理请求返回json字符串的中文乱码问题 -->
<mvc:annotation-driven>
<mvc:message-converters>
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>application/json;charset=UTF-8</value>
</list>
</property>
</bean>
</mvc:message-converters>
</mvc:annotation-driven>

以上两种方式经过验证都没有问题。

最新文章

  1. Android ListView初始化简单分析
  2. SGU 142.Keyword
  3. 下拉框Html.DropDownList 和DropDownListFor 的经常用法
  4. Mysql操作个人收集
  5. poj 1456 Supermarket(并查集维护区间)
  6. 【转】Objective-C Runtime
  7. 编译虚拟机jvm——openjdk的编译
  8. mysql索引规范
  9. 熟悉常用的HDFS操作
  10. Google 浏览器好用插件推荐
  11. 详解HTTPS、TLS、SSL
  12. AI算法第三天【矩阵分析与应用】
  13. css组合选择器
  14. 在Android源码中查找Java代码中native函数对应的C++实现
  15. 关于网站中Logo部分的写法
  16. web.xml配置遇到的问题
  17. Ubuntu登录Windows Server 2008r2 密码总是错误与NLA验证
  18. My97DatePicker基本用法
  19. eclipse zg项目学习
  20. 使用Nmon_Analyzer excel 问题总结

热门文章

  1. Python 下划线
  2. codeforces-1132 (div2)
  3. linux下安装kubectl
  4. [Android] Android 手机下 仿 微信 客户端 界面 -- 微聊
  5. BeautifulSoup爬网页图片
  6. eclipse出现jdk版本更新导致无法启动
  7. 【gitlab】gitlab快速部署教程
  8. 2018-2019-2 网络对抗技术 20165231 Exp2 后门原理与实践
  9. js 个人笔记
  10. python把列表前几个元素提取到新列表