JAX-RS @PathParam How to pass a String with slashes, hyphens & equals too

后端 未结 5 1740
北荒
北荒 2020-12-14 14:36

I am new to JAX-RS and I am trying to use Jersey to build a simple RESTful Webservice.

I have 2 questions. Please clarify these:

  1. I am trying to have

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-14 15:06

    The parameters should be URL encoded. You can use java.net.URLEncoder for this.

    String encodedParam = URLEncoder.encode(unencodedParam, "UTF-8");
    

    The / will then be translated to %2F.

提交回复
热议问题