1

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?

Peter Penzov
  • 1,126
  • 134
  • 430
  • 808

1 Answers1

1

your controller method should be like this with RequestParam to get the values from request, you can make RequestParam optional withrequired=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";
}
Ryuzaki L
  • 37,302
  • 12
  • 68
  • 98