URL encoding using the new Spring UriComponentsBuilder

后端 未结 3 802
清歌不尽
清歌不尽 2020-11-30 08:31

I\'m attempting to use spring\'s UriComponentsBuilder to generate some urls for oauth interaction. The query parameters include such entities as callback urls and parameter

3条回答
  •  无人及你
    2020-11-30 09:11

    UriComponentsBuilder is encoding your URI in accordance with RFC 3986, with section 3.4 about the 'query' component of a URI being of particular note.

    Within the 'query' component, the characters '/' and ':' are permitted, and do not need escaping.

    To take the '/' character for example: the 'query' component (which is clearly delimited by unescaped '?' and (optionally) '#' characters), is not hierarchical and the '/' character has no special meaning. So it doesn't need encoding.

提交回复
热议问题