Integrating Struts 2 with Spring Security
Let's first set up a Struts 2 application and integrate Spring Security with it.
Getting ready
Eclipse Indigo or higher version
JBoss as server
Struts 2 JARs: 2.1.x
Spring-core JARs 3.1.4. Release and Spring-Security 3.1.4.Release
Struts 2 Spring plugin jar
How to do it...
In this section, we will learn how to set up the Struts 2 application with form-based Spring Security:
In your Eclipse IDE, create a dynamic web project and name it
Spring_Security_Struts2
.Create a source folder at
src/main/java
.Create a
struts.xml
file under the source foldersrc/main/java
.To integrate Struts 2 with the Spring application, add the
application-context.xml
file reference here.Add the Struts filter mapping in
web.xml
. Spring listener also needs to be added to theweb.xml
file. The listener entry should be above the Struts 2 filter entry.The
contextLoaderListener
will tell theservletcontainer
about thespringcontextLoader
and it will track events. This also allows the developers...