abu*_*der 8 routes playframework playframework-2.0
我想得到url-param id,但它不起作用.大家能帮助我吗?以下代码不起作用.
网址:
http://localhost:9000/rest/alerts?ids[]=123?ids[]=456
Run Code Online (Sandbox Code Playgroud)
Routes.conf
GET /restws/alerts{ids} controllers.AlertService.findAlertsForIds(ids: List[String])
Run Code Online (Sandbox Code Playgroud)
AlertService.java
public static Result findAlertsForIds(List<String> ids){
return ok("Coole Sache");
}
Run Code Online (Sandbox Code Playgroud)
mgu*_*min 31
这种参数绑定与查询字符串参数一起开箱即用.
您的路线必须如下声明:
GET /restws/alerts controllers.AlertService.findAlertsForIds(ids: List[String])
Run Code Online (Sandbox Code Playgroud)
您的网址应遵循以下模式:
http://localhost:9000/rest/alerts?ids=123&ids=456
Run Code Online (Sandbox Code Playgroud)
小智 1
尝试像这样将 id 作为字符串传递
http://<hostname>:9000/rest/alerts?ids=123,456,789
然后通过对字符串应用 split() 函数来获取数组。
希望能帮助到你。
| 归档时间: |
|
| 查看次数: |
5192 次 |
| 最近记录: |