1.在前台javascript里使用encodeURI(须传递的中文字符串)
xmlHttp.open("get","cust.do?method=checkUser&custName="+encodeURI(custName));//encodeURI()处理中文:编码。
有点地方说要使用两层encodeURI(encodeURI((须传递的中文字符串)).我试了下不能解决中文乱码,只需一层就可以了。
2.后台servlet处理:
String custName = request.getParameter("custName");
String custName2 = new String(custName.getBytes("ISO-8859-1"), "utf-8");
这样就可以把页面传来的中文字符完整的解析出来。