Objective
This article uses a simple example to introduce the use of idea integration struts2+spring4+hibernate5+mysql, the great God skipped, the end of the article with the source code download connection. 1. Database Design
First in MySQL new "SSH" database, new "product" table: including PID, pname, Price field, and set the PID primary key, automatic increment.
2, new project import jar package
Idea New Java Enterprise Project to import the necessary jar packages for Struts2, Spring4, Hibernate5, and of course, a jar package to connect mysq.
3. Write Java code and configuration file (CORE)
Code layering:
Action, Service, Dao, and domain layer.
Configuration file:
Web.xml (Configure Struts2 's core filters and spring's core listeners)
Log4j2.xml (Configuration Log)
Struts.xml (Configure action)
Applicationcontext.xml (Configure dependency Injection, transaction management, and Hibernate related properties, and data sources)
4, the writing interface
Here as a test, there is only one page: addproduct.jsp. 5, testing
To view the table records of a database:
6, download
1, this example source code download
2, Struts2+spring4+hibernate5+mysql the basic jar package download