JavaWeb


创建web项目

  1. 实现servlet接口重写service方法
  2. 继承HttpServlet实现类改写doGet方法/doPost方法

遇到的问题:

??中文乱码问题(get不会乱码,post会乱码)

  1.  post设置 request.setCharacterEncoding(“UTF-8”);
  2. String value = new String(paraMap.get(item)[i].getBytes(StandardCharsets.ISO_8859_1),StandardCharsets.UTF_8);
  3. 在web.xml中配置utf-8
  4. Tomcat8 以后tomcat的默认编码已经不是ISO-8859-1,而是改成了UTF-8
SSM