In this project, we are going to see how to implement Spring MVC framework to make a login form that verifies entered username and password. If the username and password is correct then Success page is shown telling that user has successfully logged in, otherwise it will display a message that details are not correct.
If you want to run this (Spring MVC Form) whole project as it is on you local machine then after downloading this repository go to Netbeans IDE. From NetBeans ID > go to open project and then select folder named as "Spring6" (which you will find inside the zip file, (Java Programs > SpringMVCFormExample> Spring6) that you will download. After opening Spring6 in Netbeans you only need to deploy and run the project.
To create this project from scratch in Netbeans IDE follow the steps below:
- Step 1: Go to File
- Step 2: Select New Project
- Step 3: Select Java Web In Catagories and then select Web Application. Press Next.
- Step 4: Enter any name for your web application e.g. "Spring6" . Note you don't need to write Spring6 you can write anything you like. Press Next.
- Note: No need to check the checkbox which says, "use dedicated folder for storing libraries".
- Step 5: Now you will get four fields. In Add to enterprise application, I chose None. In server, I have selected GlassFish Server 4.1.1. and for Java EE version I chose Java EE 7 Web. In contextPath, it already comes prefilled. In case it is not written you need to write /nameOfApplication for e.g. your project name is Spring6 then write /Spring6. Press Next.
- Step 6: This step is most important, here don't forget to check the checkbox of Spring Web MVC. This will automatically add relevant libraries to your project. Don't check any other thing except Spring Web MVC.
- Step 7: Press Finish.