Struts: used for VC, that is, control and display;
Spring: used for transaction processing of database operations. It is OK after being configured in the configuration file;
Hibernate: used for Dao processing. Here, the gethibernatetemplate () method of spring is used to operate hsql for data addition, deletion, modification, and other operations.
1. Let's talk about your presentation layer first.
In fact, there is no need to use struts unless you have historical issues and have to use struts, because spring MVC is good enough:
A. clear model object transmission. This model object can be any Java object. If you do not care about passing the same object between layers, this model object can be hibernate's Persistent Object, with open session in view, you can use business model objects in a consistent manner.
B. Reference data, allowing you to clearly process the look up data.
C. Multiple View parsing types are available. You can define the logic name of the page in the prpperties file, or define the struts tiles logic name in the XML file.
D. for data binding without interference, a <spring: bind> model object can be bound to the form, just like the formbean automatically filled by struts, but the binding function of spring does not interfere with the interface layout, in other words, you can still use the HTML editor to process the page.
E. Client verification.
F. server-side verification.
G. A variety of available controllers, which support form controllers, provide functions similar to form event processing in VB. This is a series of workflows that insert your processing where you think it is appropriate.Code.
Compared with Struts, spring MVC may only lose a lot of taglib and page layout, but this can be supplemented by a third-party tool, because the view is more lightweight than other parts. Third-party tools that can be selected can be displaytag, Struts-menu, Struts tiles, and so on.
2. Let's talk about the business logic section.
The business logic class can be configured with spring beans, and the relationship between spring management and the Controller at the presentation layer and the DaO object at the lower layer is also discussed. In addition, you can also perform configuration-based transaction processing. An Interceptor configuration removes all your troubles.
3. Dao Layer
Use the hibernate API encapsulated by spring to keep hibernate slim and establish the relationship with the upper layer through spring.
4. At last, let's talk about the Po of hibernate.
You can choose any method you like for modeling. the following tools provide sufficient support:
A. From a Java object to an HBM file: XDoclet
B. From HBM file to Java object: hibernate Extension
C. From database to HBM file: middlegen
D. From HBM file to database: schemaexport
For reference projects, can you look at the example of spring petclinic (Spring + hibernate), there is also an undeniable site: http://raibledesigns.com/wiki/Wiki.jsp? Page = appfuse (STRUTS + spring + hibernate or spring MVC + spring + hibernate ). In addition, the MVC step-by-step in spring is a good getting started tutorial.
It should be noted that spring only provides us with a way to design and implement the Framework. Therefore, the success of the project is closely related to our architectural design, with good design ideas, making good use of spring will make it easier for us to succeed.