通常在URl中需将中文转成百分号编码
package org.mobiletrain;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
public class Test03 {
public static void main(String[] args) {
String str = "王大锤";
String str2;
try {
//将中文转换成百分号编码(URL中需要使用百分号编码)
str2 = URLEncoder.encode(str,"utf-8");
System.out.println(str2);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
}