I was looking at requests from Spring Boot
and I saw that you can make a request POST
, in two ways:
//primeira forma
@RequestMapping(value = "/dev", method = RequestMethod.POST)
public ResponseEntity<String> dev(@RequestParam("nome") String nome) {
return new ResponseEntity<String>(nome, HttpStatus.OK);
}
//segunda forma
@PostMapping("/dev")
public ResponseEntity<String> nome(@RequestParam("nome") String nome) {
return new ResponseEntity<String>(nome, HttpStatus.OK);
}
I tested with Postman
and both returned the same result.
-
What's the difference between these two forms?
-
Is there any limitation on either?
-
Which is more appropriate when you are going to send data from a form, example?