1.

1 import java.net.URLDecoder;
2 import java.net.URLEncoder;
3 
4 String strTest = "?=abc?中%1&2<3,4>";
5 strTest = URLEncoder.encode(strTest, "UTF-8");
6 System.out.println(strTest);
7 strTest = URLDecoder.decode(strTest,"UTF-8");
8 System.out.println(strTest);

 

2.结果

%3F%3Dabc%3F%E4%B8%AD%251%262%3C3%2C4%3E
?=abc?中%1&2<3,4>