Spring MVC Password tag Example

Spring MVC password tag is used to show a password field on the UI

The HTML code that gets generated is

You can get more information on the various attributes that can be used in the password tag at the
Spring form TLD


Lets see a full example of the login page where the Spring MVC password tag is used.

1. Create a Model Class

2. Create a Controller
In this example Controller is used to process the login form

3. Login, Success and Error Pages
Create 3 jsp pages.
login.jsp has the login form. Note that the request method of the form should be same as the requestMethod of the Controller method that will be handling the form request.


Spring MVC Sample | Spring MVC Password Tag with Example

Enter username = admin and password = admin123 for Success page to be displayed.

Any other values will display the error page.

Download the Source Code : – SpringMVC-sampleLoginProject.zip