String s="测试ss";
s=java.net.URLEncoder.encode(s,"UTF-8");
System.out.println(s);

s=java.net.URLDecoder.decode(s,"UTF-8");
System.out.println(s);

控制台输出:
%E6%B5%8B%E8%AF%95ss
测试ss