前端请求restful风格接口怎么传参_如何将多个参数传递/接收到RESTful Web API GET方法?...

在RESTful API中,通常GET方法通过URL中的ID参数获取资源。若需传递多个参数,例如字符串和整数,可以通过定义接受多个参数的方法,如`Get(string someString, int someInt)`。在Web API 2中,可以使用属性路由明确指定如`api/{controller}/{name}/{id}`的路径。此外,通过默认配置,Web API能够将查询字符串参数映射到方法,如`http://192.112.183.42:80/api/platypusItems/42?name=DuckbilledPlatypisAreGuysToo`会映射到`GetItemByNameAndId`。" 135312123,7337247,神经网络优化:动态调整与在线学习实战,"['人工智能', '深度学习', '优化算法', '自然语言处理', '计算机视觉']
摘要由CSDN通过智能技术生成

The usual examples of GET RESTful methods that take a parameter (returning a scalar value rather than a dataset) are shown like so:

public string Get(int id)

{

//get and return the value

}

...where the val passed is typically an ID, so you can use it to get a scalar value based on that unique value.

What, though, if you want to pass multiple values, such as a string and an int? Is it simply a matter of defining a method like so:

public string Get(string someString, int someInt)

{

//get and return the value

}

...and calling it like so:

//const string uri = "http://192.112.183.42:80/api/platypusItems/someString/someInt";, zB:

const string uri = "http://192.112.183.42:80/api/platypusItems/DuckbilledPlatypisAreGuysToo/42";

var webRequest = (Ht

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值