1.html修改

#Servlet#获取参数request&返回响应response之中文乱码问题

html 头文件中加入上图中红线部分 

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

2.servlet修改

#Servlet#获取参数request&返回响应response之中文乱码问题 

byte[] bytes= name.getBytes("ISO-8859-1");

name = new String(bytes,"UTF-8");

request.setCharacterEncoding("UTF-8");

根据utf-8解码;

response.setContentType("text/html; charset=UTF-8");

返回中文之响应;

相关文章: