get param spring boot code example

Example 1: spring url parameter

@RequestMapping("/{someID}")
public @ResponseBody int getAttr(@PathVariable(value="someID") String id, 
                                 @RequestParam String someAttr) {
}

Example 2: postmapping mulitple params same name in spring boot

@RequestMapping(value="/params", method = RequestMethod.GET)
public ResponseEntity getParams(@RequestParam Map<String, String> params ) {

   System.out.println(params.keySet());
   System.out.println(params.values());

   return new ResponseEntity<String>("ok", HttpStatus.OK);
}

Tags:

Java Example