日期:2014-05-18  浏览次数:20657 次

关于链接的问题?
如何把
http://localhost:7001/ax.do?q= "汉字 "
变成
http://localhost:7001/ax.do?q=java+url%E9%87%8D%E5%86%99
这种乱码java+url%E9%87%8D%E5%86%99是如何形成的

------解决方案--------------------
顶。。。学习中。。。。。。。。
------解决方案--------------------
等待高手解答...
------解决方案--------------------
应该是你的编码问题吧,最好用UTF-8
------解决方案--------------------
汉字的编码问题
------解决方案--------------------
字符转码 GBK--> UTF-8/ISO-8859-1
------解决方案--------------------
我也正要用,借下了
GBK--> UTF-8/ISO-8859-1
会不会把jsp的boby的汉字也乱码了
------解决方案--------------------
URLEncode:一般为地址栏中的中文字加密时使用,转换后,原明文的汉字将变成加密字符串,但可被浏览器识别。
URLDecode:转换为UTF-8字符串。GOOGLE 搜索引擎就是使用这种编码来搜索中文的。

楼主,http://54caizi.com/tools/encode.asp 这个编码转换工具不错,你可以看看。
------解决方案--------------------
楼上说得很明白了,我在补充一下,你的那个 "%E9%87%8D%E5%86%99 "就是 "重写 "这个次用URLDecode编码后的格式.在楼上提供的网站里面用UFT-8字符还原就可以看到结果了!
------解决方案--------------------
//中文参数编码
static {

try {
Class[] args = new Class[]{String.class, String.class};
encode = URLEncoder.class.getMethod( "encode ", args);
} catch (NoSuchMethodException e) {
System.out.println( "Could not find Java 1.4 encode method. Using deprecated version. "+ e);
}
}
public static String encodeURL(String url, String enc) {
try {

if(enc==null || enc.length()==0){
enc = "UTF-8 ";
}
if (encode != null) {
return (String) encode.invoke(null, new Object[]{url, enc});
}

} catch (IllegalAccessException e) {
System.out.println( "Could not find Java 1.4 encode method. Using deprecated version. "+ e);
} catch (InvocationTargetException e) {
System.out.println( "Could not find Java 1.4 encode method. Using deprecated version. "+ e);
}
return URLEncoder.encode(url);
}
//具体的位置使用
String url=req.getContextPath()+m.getPath()+ ".do?key= " + key + "&value= " + encodeURL(value, "UTF-8 ");