URL Encode and Decode Special character in Java

前端 未结 4 1913
清酒与你
清酒与你 2020-12-29 07:19

In Java, I need to use HTTP Post to send request to server, but if in the parameter of the URL contains some special character it throws below Exception

4条回答
  •  孤独总比滥情好
    2020-12-29 08:18

    try guava

    use com.google.common.net.UrlEscapers

    it works fine with chinese

    like this:

    Escaper escaper = UrlEscapers.urlFragmentEscaper();
    String result = escaper.escape(yoururl);
    

提交回复
热议问题