1. encode.html
<script language="JavaScript">
document.write(encodeURI('http://www.blogjava.net/chenlb/abc 中文'));
</script>
2.
decode.jsp
/*
* <script language="JavaScript">
* document.write(encodeURI('http://www.blogjava.net/chenlb/abc 中文'));
* </script>
*/
String url = "http://www.blogjava.net/chenlb/abc%20%E4%B8%AD%E6%96%87";
try {
System.out.println(URLDecoder.decode(url, "UTF-8"));
System.out.println(URLDecoder.decode(url, "GBK"));//乱码
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
posted on 2007-10-13 21:27
流浪汗 阅读(9841)
评论(6) 编辑 收藏 所属分类:
HTML