There are Chinese data transfer, the server-side access to the garbled, how to solve? ! Reply:
Before doing jsp is solvedString str = new String (request.getParameter ("something") getBytes ("ISO-8859-1"), "utf-8".);
Should be able to refer to the Reply:
getBytes become ("ISO-8859-1"), at least you know you pass over the ISO-8859-1 encoding, ah, before it can be converted, and I do not know what to pass over coding, and obviously have been set up in the client utf-8 a. Your method does not work in my die, ah,,,, Reply: Returns the result string in the encoding process to try to do something too:
Plus without all the effects! ! ! Great God who can solve the small brother doubts ah! ! ! ! ! ! ! ! !
Reply: URLDecoder.decode is decoded to. LZ data transmitted with the encoded URLEncoder.encode, when receiving the decoded then URLDecoder.decode Reply:
These methods online that I have tried! ! ! You said the way I have tried! ! ! This is the way to generate the final return json is what you said.
public String MakeDiaryJson (String title, String context, String createtime, String lastmodifytime, int user_id) throws Exception { String diaryjson = ""; JSONObject json = new JSONObject (); try { Diary title / / diary of depositjson.put ("title", title); Diary / / diary of depositjson.put ("context", context); / / Diary diary of deposit creation time json.put ("createtime", createtime); The last time / / diary of deposit diary Modified json.put ("lastmodifytime", lastmodifytime); Diary of a foreign key into the diary, that this diary belongs to which user / /json.put ("user_id", user_id); diaryjson = json.toString (); URLDecoder.decode (diaryjson, "utf-8"); } Catch (JSONException e) { / / TODO Auto-generated catch block Log.i ("JSonInfo:", "!!!! MakeDiaryJson create failure"); } return URLDecoder.decode (diaryjson, "utf-8"); };
Server code:
public String execute () throws Exception { / / TODO Auto-generated method stub System.out.println ("execute () method was executed!!!"); try { BufferedReader br = new BufferedReader (new InputStreamReader ((ServletInputStream) request.getInputStream ()));
String line = ""; StringBuilder sb = new StringBuilder (); while ((line = br.readLine ())! = null) { sb.append (line); } System.out.println ("diaryjson:" + URLDecoder.decode (sb.toString (), "utf-8"));
No comments:
Post a Comment