1.java内部加密和解密
String mytext = java.net.URLEncoder.encode("中国", "utf-8");
String mytext2 = java.net.URLDecoder.decode(mytext, "utf-8");
这两条语句在同一个页面中的话,得到的结果是:
mytext: %E4%B8%AD%E5%9B%BD
mytex2: 中国
2.通过浏览器传回的中文解密
String zhongguo=new String(request.getParameter("zhongguo").getBytes("iso8859_1"));
zhongguo=java.net.URLDecoder.decode(zhongguo,"utf-8");