1.对象 request response 对象setCharacterEncoding=UTF-8
1 <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> 2 <% 3 //解决post/get 请求中文乱码的方法 4 request.setCharacterEncoding("UTF-8"); 5 response.setCharacterEncoding("UTF-8"); 6 %> 7 8 9 10 11代码段标签 12 13 14 <%! 15 int name;16 int password;17 %>18 <%19 String name=request.getParameter("username");20 String password =request.getParameter("pwd");21 out.println("hello "+name+" success! "+"");22 out.println("密码泄露 "+password);23 %>24
2. 方法二 (比较简单)
找到tomcat 配置文件 server.xml ,加入code: URIEncoding="utf-8"
15