Posting Data
Learn how to handle changes made to the data by a user.
We'll cover the following...
We'll cover the following...
Posting data
We saw how to use @GetMapping to display information to the user. Inevitably, the user will also want to change data. In web terms, we can do this by using HTTP POST with a <form>.
Suppose we have a form to change the name of a team. The controller method to make that possible could look something like this:
- Use the
@PostMappingannotation to indicate that aPOSTcall to/teams/<id>should be handled by this method. - The
editTeamFormDatais