想要处理中文,就要统一编码,使用UTF-8
获取中文的参数
- 使用UTF-8编码:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- login.html里form的method改为post
- servlet里加上:
req.setCharacterEncoding("UTF-8");
- 在servlet进行编码和解码
返回中文的响应
- 在Servlet中,加上:
resp.setContentType("text/html; charset=UTF-8");