Authenticating databases with Struts 2 and Spring Security
In this section, let us authorize the user who logs into the Struts 2 application using the information stored in the database. Spring Security needs to be configured in Struts 2 application such that it gets to know the location of the database and SQL that needs to be executed to authenticate the user using Spring Security.
Getting ready
- Create a dynamic web project in Eclipse:
Struts2_Spring_DBAuthentication_Recipe4
- Copy the
struts.xml
file tosrc/main/java
- Add the
db-beans.xml
file toWEB-INF
- Copy the
webContent
folder from the previous recipe - Add the following JARs into the
lib
folder or update your POM file if you are using maven:- spring-jdbc-3.0.7.RELEASE
- mysql-connector-java-5.1.17
- commons-dbcp
- commons-pool-1.5.4
How to do it...
- To perform database authentication with Struts 2 and Spring, we need to create a
db-beans.xml
file. Thedb-beans.xml
file will have database information:<beans xmlns="http://www.springframework.org/schema...