Jax-rs automatic decode pathparam

前端 未结 2 2103
感动是毒
感动是毒 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.

提交回复
热议问题