直接在Servlet里添加转换的代码:
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//解决中文乱码
response.setContentType("text/html;charset=utf-8");
//请求解决乱码
request.setCharacterEncoding("utf-8");
//响应解决乱码
response.setCharacterEncoding("utf-8");
//输出
PrintWriter out = response.getWriter();
String name=request.getParameter("name");
out.println(name);
}