Java有時在執行get,post請求時,參數有時是中文,此時需要轉碼,纔可請求!
import java.net.URLEncoder;
String username = URLEncoder.encode("張三", "UTF-8");
String url = "https://test.com/api/login?username="+username;
https://test.com/api/login?username=%E5%BC%A0%E4%B8%89
Java有時在執行get,post請求時,參數有時是中文,此時需要轉碼,纔可請求!
import java.net.URLEncoder;
String username = URLEncoder.encode("張三", "UTF-8");
String url = "https://test.com/api/login?username="+username;
https://test.com/api/login?username=%E5%BC%A0%E4%B8%89