Reputation: 1680
I want to get the values from this http link:
https://www.test.com/notification?con=41280440000097&dp=1232&type=single
https://www.test.com/notification?con=41280440000097&sec=1232
I tried to implement this Spring code:
@PostMapping(value = "/v1/notification")
public String handleNotifications(@RequestParam("notification") String itemid) {
// parse here the values
return "result";
}
But how I can parse the http link and get the values for example in ArrayList of HashMap?
Upvotes: 2
Views: 511
Reputation: 40078
your controller method should be like this with RequestParam
to get the values from request, you can make RequestParam optional with
required=falseand 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";
}
Upvotes: 2