import java.net.URLDecoder;
import java.net.URLEncoder;
String strTest = "?=abc?中%1&2<3,4>";
strTest = URLEncoder.encode(strTest, "UTF-8");//转码
System.out.println(strTest);
strTest = URLDecoder.decode(strTest,"UTF-8");//解码
System.out.println(strTest);
结果:
%3F%3Dabc%3F%E4%B8%AD%251%262%3C3%2C4%3E
?=abc?中%1&2<3,4>