Time for action – serving and processing forms
The Spring tag library provides some special <form>
and <input>
tags that are more or less similar to HTML form and input tags, but it has some special attributes to bind the form elements data with the form-backing bean. Let's create a Spring web form in our application to add new products to our product list by performing the following steps:
- We open our
ProductRepository
interface and add one more method declaration in it as follows:void addProduct(Product product);
- We then add an implementation for this method in the
InMemoryProductRepository
class as follows:public void addProduct(Product product) { listOfProducts.add(product); }
- We open our
ProductService
interface and add one more method declaration ...
Get Spring MVC Beginner’s Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.