Spring and Struts 2 Integration

Spring structure gives a simple method to deal with the reliance. It very well may be effectively coordinated with struts2 2 framework.

The ContextLoaderListener class is utilized to impart spring application with struts2 2. It must be indicated in the web.xml file.


You need to follow following steps:

  1. Create struts2 application and include spring container files.
  2. In web.xml document, characterize ContextLoaderListener class.
  3. In struts.xml document, characterize bean name for the activity class.
  4. In applicationContext.xml document, make the bean. Its class name ought to be activity class name for example com.javatpoint.Login and id should coordinate with the activity class of struts.xml document (for example login).
  5. In the action class, characterize additional property for example message.

Example of Spring and Struts 2 Integration

You need to create following files for simple spring and struts 2 application:

  1. index.jsp
  2. web.xml
  3. struts.xml
  4. applicationContext.xml
  5. Login.java
  6. welcome.jsp
  7. error.jsp





javacodegeeks is optimized for learning.© javacodegeeks .
All Right Reserved and you agree to have read and accepted our term and condition