liveBook · Manning

@postmapping

As explained in Spring Start Here, Second Edition

The @PostMapping annotation maps a Spring MVC method to HTTP POST requests for a specified path.

@PostMapping maps a Spring MVC controller method to HTTP POST requests at a specified path. It makes the HTTP method explicit, unlike @RequestMapping without a method, which matches all HTTP methods. section 8.2

Add a product

Use @PostMapping("/products") on an action that receives a product’s name and price, adds it to the product list, and returns the updated products page. An HTML form with action="/products" and method="post" sends the request. section 8.2

How Spring Start Here, Second Edition covers it

How deep it goes
Shows path mapping and a product-action example, and contrasts dedicated method annotations with @RequestMapping.
Examples
Demonstrates adding a product through a POST action and an HTML form targeting /products.
What you can do after
Apply @PostMapping to route a form submission to a Spring MVC action that adds a product.
How it connects
Connects Spring MVC controller methods with HTTP POST, @RequestMapping, request parameters, and HTML forms.

Also explained in

Compare how 2 books explain @postmapping →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Spring Start Here, Second Edition. The section links point to the parts of the book it draws on.