REST how to pass values containing “/” as path par

2020-08-01 06:07发布

问题:

I am developing a Client using HttpClient in Java to access a REST Application. In this i want to pass two parameters name(value="Kiran") and address(Value="5th Corner/Road") as path parameters .

Sample url:-http://localhost:port/rest/name/Kiran/address/5th Corner/Road

But as address contains "/" as value, its not taking the actual value. Is there a way to handle "/" while accessing REST applications from Java.

Any help is appreciated.

回答1:

Use java.net.URLEncoder to encode the query parameters.



标签: java rest get