一、乱码原因

request域中文乱码问题

页面默认使用的是UTF-8的编码方式,服务器端默认使用 iso8859-1的编码方式

二、解决方式

1、表单是post方式提交时

设置request的编码

 request.setCharacterEncoding("UTF-8");

2、表单是get/post方式提交时

  String username = request.getParameter("username");//乱码
   //先用ios8859-1编码在使用utf-8解码
   username = new String(username.getBytes("ios8859-1"),"UTF-8");

相关文章:

  • 2022-01-25
  • 2021-09-26
  • 2022-02-09
  • 2022-12-23
  • 2021-07-26
  • 2021-07-09
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-07
  • 2021-09-27
相关资源
相似解决方案