文档介绍:... ... : function verify() {//解决中文乱码问题的方法1,页面端发出的数据做一次encodeURI ,服务器端使用new String(("iso8859-1"), "UTF-8"); //解决中文乱码问题的方法 2,页面端发出的数据做两次 encodeURI ,服务器端使 (old, "UTF-8"); var userName =$("#userName").val(); $.get("AjaxServer?name="+encodeURI(encodeURI(userName)), null, function(data){ $("#result").html(data); }); }推荐使用方法 2,因为方法 1中使用硬编码“ISO-8859-1 ”了。 : import ; import ; import .URLDecoder; import ; import ; import ; import ; import ; import ; /** *Servlet implementation class AjaxServer */ ... ... ***@WebServlet(description ="wh description", urlPatterns ={"/AjaxServer" },initParams ={***@WebInitParam(name ="name", value ="", description ="wh name") }) public class AjaxServer extends HttpServlet { private static final long serialVersionUID =1L; /** ****@see HttpServlet#HttpServlet() */public AjaxServer() {super(); //TODO Auto-generated constructor stub }/** ****@see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse *response) */protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try {("text/html; charset=UTF-8"); //("UTF-8"); PrintWriter out =(); Integer inte =(Integer) ().getAttribute("total"); int temp =0; ... ... if(inte ==null) temp =1; else temp =() +1; ().setAttribute("total", temp); // String old =("name"); //String name =new String(("ISO-8859-1"), "UTF-8"); String name =(old, "UTF-8"); // if(old ==null ||() ==0){ (" 用户名不能为空"); }else {// if(("wangxingkui")) { //。这一步需要