91-9990449935 0120-4256464 |
Login Example with Spring and Struts 2 IntegrationIn the previous example, we have simply integrated the spring application with struts 2. Now let's develop a login application with struts 2 and spring frameworks. It is the simple example of login application without database and session management. If you need to apply the database interactivity and session management with this example, visit this link Login and Logout example in struts 2.Example of Login application Spring and Struts2 IntegrationYou need to create following files for simple login application using spring and struts 2 application:
This page gets the name and password from the user. 2) web.xml It defines controller class for struts 2 and ContextLoaderListener listener class to make connection between struts2 and spring application. 3) struts.xml It defines the package with action and result. Here, the action class name is login which will be searched in the applicationContext.xml file. 4) applicationContext.xml It defines a bean with id login. This beans corresponds to the com.javatpoint.Login class. It will be considered as the action class here. 5) Login.java It defines four properties name, password, successmessage and errormessage; with execute method where success is returned if password is javatpoint. 6) login_success.jsp It prints values of userName and message properties. 7) login_error.jsp It is the error page. But it is not required in this example because we are not defining any logic in the execute method of action class. |