我想从此http链接获取值:
https://www.test.com/notification?con=41280440000097&dp=1232&type=single
https://www.test.com/notification?con=41280440000097&sec=1232
我尝试实现此Spring代码:
@PostMapping(value = "/v1/notification")
public String handleNotifications(@RequestParam("notification") String itemid) {
// parse here the values
return "result";
}
但是我如何解析http链接并获取HashMap的ArrayList中的值?
答案 0 :(得分:1)
您的控制器方法应与RequestParam
类似,以从请求中获取值,您可以使RequestParam optional with
required = false and you can set default value also
(@ RequestParam(value =“ i”,defaultValue =“ 10”)int i`
@PostMapping(value = "/v1/notification")
public String handleNotifications(@RequestParam(value="con", required=false) String itemid, @RequestParam(value="dp", required=false) String dp, @RequestParam(value="type", required=false) String type )
{
// you can use all these values directly in this method
// parse here the values
return "result";
}