随笔 - 3, 文章 - 6, 评论 - 0, 引用 - 0
数据加载中……

2006年11月13日

中文参数乱码

使用java.net.URLEncoder.encode()可以对要传递的中文进行编码

encode:
word = java.net.URLEncoder.encode("中文字符","GB2312");

decode:
//request.setCharacterEncoding("GBK");
   String str=request.getParameter("word");
   str=java.net.URLDecoder.decode(str,"GB2312");
   str=new String(str.getBytes("ISO-8859-1"));

posted @ 2006-11-13 14:48 drh0r 阅读(265) | 评论 (0)编辑 收藏