Struts + Spring + Hibernate Analysis

xiaoxiao2021-03-06  140

1, let's talk about your representation layer

In fact, there is no need to use Struts unless you have a historical legacy problem to use Struts, because Spring's MVC is already good enough:

a. Clear model object passes, this model object can be any Java object, if you don't care about passing the same object between the layers, this model object can be Hibernate's persistent object, through Open session in view, you Business model objects can be used in a consistent manner.

B.Reference Data, let you clear the Look Up data.

c. A variety of available view parsing types that define the logical name of the Page in the prperties file, or define the Struts Tiles logical name in the XML file.

d. No interference data binding, one can bind the model objects and Form, just like Struts automatically populate FORMBEAN, but Spring's binding function does not interfere with the interface layout, that is, you You can still process the page using the HTML editor.

e. Client verification.

f. server side verification.

g. A variety of optional controllers, where the controller for supporting the form provides a function similar to the VB's formal event processing, which is a series of Workflow, inserting your processing code in place where you think it is appropriate.

Spring MVC is compared to Struts, it may just have a lot of Taglib and page layouts, but this can be added through third-party tools, because the view is more lightweight than other parts. The third-party tool that can be selected can be: DisplayTag, Struts-Menu, Struts Tiles, and more.

2, talk about business logic

Business Logic class can be configured with Spring Beans and manage the relationship between the controller of the performance layer and the lower-level DAO object. In addition, you can perform configurable transaction, an interceptor configuration, eliminating all your worries.

3, DAO layer

The Hibernate API encapsulated with Spring, let Hibernate continue to slim, and establish the relationship with the upper layer via Spring.

4, final, talk about Hibernate's PO

You can choose any way you like, and the following tools provide enough support:

a. From the Java object to HBM file: xdoclet

b. From HBM files to Java objects: Hibernate Extension

c. From the database to HBM file: MiddleGen

d. From HBM files to the database: SchemaExport

As for the reference, you can check out the example of Spring PetClinic (Spring Hibernate), there is a non-viewable website: http://raibledesigns.com/wiki/wiki.jsp? Page = Appfuse (Struts Spring Hibernate or Spring MVC Spring Hibernate). In addition, Spring's MVC Step-by-Step is a good start-up tutorial.

It should be noted that Spring only provides us with a way of designing and implementing a framework, so the success of the project is closely related to our architecture design, after having a good design idea, make good use Spring Will make our success easier.

转载请注明原文地址:https://www.9cbs.com/read-127519.html

New Post(0)