Today, when invoking an interface, a Chinese parameter needs to be passed, resulting in no data being obtained because of the encoding problem of the Chinese-language parameter.
Source of the problem: URL url= new URL ("http://XXX?OrganName= Justice Department");
The present solution is as follows:
1. Encode the Chinese characters that you want to pass the URL to:
String message = Java.NET.URLEncoder.encode("Judicial Hall", "Utf-8");
2, in the URL to pass the Chinese page to decode the characters:
String msg = request.getparameter ("message");
String Str=new string (msg.getbytes ("iso-8859-1"), "UTF-8");
--------------------------------------------------------------------------------------
Note: Why to convert the character set form to UTF-8 form, because Iso-8859-1 is the standard character set used in the network transmission in Java, request.getparameter ("message"); Get the iso-8859-1 character set, so you have to convert it.
Questions about URL passing Chinese parameters in Java