Jax-rs automatic decode pathparam

前端 未结 2 2101
感动是毒
感动是毒 2021-02-13 17:02

I have a jax-rs service which receives a set of parameters in the path, pathparameters. These parameters may be strings containing values not suitable for urls, so they are urle

相关标签:
2条回答
  • 2021-02-13 17:24

    The automatic encoding of pathparams works as expected. The problem was that %20is used to encode spaces in the url itself, while + is used to encode the query string(the part after the ?). Pathparams are really parts of the URL, so %20 should be used.

    Using URI.toAsciiString() instead of UrlEncoder.encode(...) and passing the different parts gives a valid url that is decoded correctly.

    0 讨论(0)
  • 2021-02-13 17:28

    Quote from PathParam javadoc:

    The value is URL decoded unless this is disabled using the Encoded annotation.

    0 讨论(0)
提交回复
热议问题