@PostMapping
Learn @PostMapping (Controllers, Spring MVC) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
Fresher Notes @PostMapping maps HTTP POST requests to a method; it is the shortcut for @RequestMapping(method = RequestMethod.POST) and is used to create resources or submit forms. Body : send JSON and read it with @RequestBody ; for HTML forms Spring binds fields with @ModelAttribute or @RequestParam . Response : a create usually returns 201 Created with a Location header.
More lessons in Controllers
- @Controller
- @RestController
- Controller Lifecycle
- Controller Methods
- Request Mapping
- @RequestMapping
- @GetMapping
- @PutMapping
- @DeleteMapping
- @PatchMapping
- Mapping HTTP Methods
- Mapping URL Paths
- Class-Level Mapping
- Method-Level Mapping
- Multiple URL Mappings
- Consumes
- Produces
- Mini Project: Controller Types and Mapping Rules