1、在html文件中添加<meta http-equiv="content-type"content="text/html;charset=utf-8">,作用是让浏览器以utf-8的编码格式来打开页面(确保html文件本身确定是使用utf-8保存的),表单方式必须为post;
2、在服务器servlet里面,设置:request.setCharacterEncoding("utf-8"),作用是设置解码时的编码格式;
3、如果servlet在控制台要输出中文,设置:response.setContentType("text/html;charset=utf-8");
4、使用Mysql时,要注意jdbc的链接加上:useUnicode=true&characterEncoding=utf8。