try {
// Construct a x-www-form-urlencoded string
String line = URLEncoder.encode("name1", "UTF-8") + "=" + URLEncoder.encode("value1", "UTF-8");
line += "&" + URLEncoder.encode("name2", "UTF-8") + "=" + URLEncoder.encode("value2", "UTF-8");
// Parse a x-www-form-urlencoded string
String[] pairs = line.split("\\&");
for (int i=0; i<pairs.length; i++) {
String[] fields = pairs[i].split("=");
String name = URLDecoder.decode(fields[0], "UTF-8");
String value = URLDecoder.decode(fields[1], "UTF-8");
}
} catch (UnsupportedEncodingException e) {
}
// Construct a x-www-form-urlencoded string
String line = URLEncoder.encode("name1", "UTF-8") + "=" + URLEncoder.encode("value1", "UTF-8");
line += "&" + URLEncoder.encode("name2", "UTF-8") + "=" + URLEncoder.encode("value2", "UTF-8");
// Parse a x-www-form-urlencoded string
String[] pairs = line.split("\\&");
for (int i=0; i<pairs.length; i++) {
String[] fields = pairs[i].split("=");
String name = URLDecoder.decode(fields[0], "UTF-8");
String value = URLDecoder.decode(fields[1], "UTF-8");
}
} catch (UnsupportedEncodingException e) {
}
解决方案 »
- 谁有POI中文帮助文档?
- JSP基于web的电子账单查询与支付系统开发,急急急~~
- jsp中如何使用UploadBean组件实现批量上传图片
- Eclipse即在Tomcat中,如何自动生成JSP页面后,让它可以访问?
- 关于JAVABEAN读取网页源代码的问题?
- 乱码的问题,,include file问题。。。
- 新手问题,希望能得到帮助
- <c:forEach 不会用! hurry...
- 救急!!!!
- unexpected element (uri:"", local:"INSTRUMENT_ID"). Expected elements are 。。。
- JSF scope:application 的bean是什么时候初期化的?
- 当查询记录为空记录集时,查询语句中的定义排序问题
兄弟什么意思啊
String ret=null;
try {
ret=java.net.URLEncoder.encode(s, "utf-8");
} catch (UnsupportedEncodingException ex) {
}
return ret;
}
这个试过了 好像也有问题
现在的问题是 汉字 ->UTF-8 乱码 这个过程可能有字符被过滤 或者字节变化
decode utf8->汉字