Use the other encode
method in URLEncoder:
URLEncoder.encode(String, String)
The first parameter is the text to encode; the second is the name of the character encoding to use (e.g., UTF-8
). For example:
System.out.println(
URLEncoder.encode(
"urlParameterString",
java.nio.charset.StandardCharsets.UTF_8.toString()
)
);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…