1> Preferences/MyEclipse/Files and Editors jsp页面编码统一设置成UTF-8
2> 设置请求、响应的编码格式(post)
request.setCharacterEncoding("utf-8");//response.setCharacterEncoding("utf-8");
page指令的contentType里已经指定了charset的编码格式为utf-8
<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8"%>
治标:new String("中文".getBytes("iso-8859-1"),"utf-8");
治本:在apache-tomcat-8.0.12\conf\server.xml文件中添加 <Connector />
URIEncoding="UTF-8" /useBodyEncodingForURI="true";
java.net.URLEncoder.encode("中文","utf-8");
response.sendRedirect("welcome.jsp?username="
+ URLEncoder.encode(name, "utf-8") + "&upwd=" + pwd
+ "");
java.net.URLDecoder.decode(""."utf-8")
<%=URLDecoder.decode(request.getParameter("username"), "utf-8") %><p/>