Spring Security Form-Based AuthenticationForm-Based authentication is a way in which user's authentication is done by login form. This form is built-in and provided by spring security framework. The HttpSecurity class provide a method formLogin() which is responsible to render login form and validate user credentials. In this tutorial, we will create an example that implements form-based authentication. Lets start the example. Create a Maven ProjectFirst create a maven project by providing project details. This project initially looks like this: Spring Security ConfigurationConfigure spring security in the application by using the following Java files. Create a package com.javatpoint and put all the files into it. // AppConfig.java // MvcWebApplicationInitializer.java // SecurityWebApplicationInitializer.java // WebSecuiryConfig.java ControllerCreate a controller HomeController and put inside the com.javatpoint.controller package. It contains the following code. // HomeController.java ViewsThis project contains the following two view (JSP pages). Put these into WEB-INF/views folder. // index.jsp // admin.jsp Project Dependencies// pom.xml Project StructureAfter adding all these files the project structure looks like this: Run ServerRun the application over the server and see it produces the following output to the browser. Output: Click on link, a login form is rendered that will use for form-based authentication. After validating credentials it authenticate the user and render to the admin page. Next TopicSpring Security Remember Me |