Java URL encoding of query string parameters

前端 未结 12 1030
清歌不尽
清歌不尽 2020-11-21 05:27

Say I have a URL

http://example.com/query?q=

and I have a query entered by the user such as:

random word £500 bank

12条回答
  •  梦如初夏
    2020-11-21 06:08

    Using Spring's UriComponentsBuilder:

    UriComponentsBuilder
            .fromUriString(url)
            .build()
            .encode()
            .toUri()
    

提交回复
热议问题