REST如何传递包含“/”的值作为URI中的路径参数? [英] REST how to pass values containing "/" as path parameter in the URI?

查看:472
本文介绍了REST如何传递包含“/”的值作为URI中的路径参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个使用Java中的HttpClient访问REST应用程序的客户端。
在这里,我想将两个参数name(value =Kiran)和地址(Value =5th Corner / Road)作为路径参数传递。

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

但是,由于地址包含/作为值,因此不会取实际值。
有没有办法在从Java访问REST应用程序时处理/。



任何帮助表示赞赏。 使用 /net/URLEncoder.htmlrel =nofollow> java.net.URLEncoder 来编码查询参数。


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.

解决方案

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

这篇关于REST如何传递包含“/”的值作为URI中的路径参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆