原因:Android端发送的是utf-8格式,但服务器端解码格式是iso-8859-1,所以会产生乱码。
解决办法:
Android端:
String place="太仓"; try { place = URLEncoder.encode(place,"UTF-8"); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } String homeUrl = "http://" + IP + ":8080/YiQu/MultPageServlet?currentPage=" + initPage + "&pageSize=" + pageSize + "&mode=np&code=0&place="+place;
服务器端:
String placeString = request.getParameter("place").trim(); String place = new String(placeString.getBytes("iso-8859-1"), "UTF-8"); // System.out.println("placeString :"+placeString); System.out.println("place :"+place);
以上