Spring MVC Model Interface
In Spring MVC, the model works a container that contains the data of the application. Here, a data can be in any form such as objects, strings, information from the database, etc.
It is required to place the Model interface in the controller part of the application. The object of HttpServletRequest reads the information provided by the user and pass it to the Model interface. Now, a view page easily accesses the data from the model part.
Methods of Model Interface
Spring MVC Model Example
Let's create a login page that contains a username and password. Here, we validate the password with a specific value.
1. Add dependencies to pom.xml
2. Create the request page
Here, we create the login page to receive name and password from the user.
3. Create the controller class
In controller class:
4. Provide the entry of controller in the web.xml file
5. Define the bean in the xml file
6. Create the other view components
To run this example, the following view components must be located inside the WEB-INF/jsp directory.