Relationship and difference between STRUTS + spring + hibernate (zt )--

Source: Internet
Author: User
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. Non-interfering data binding, one You can bind a model object to a form, just like automatically filling formbean with Struts, but the binding function of spring does not interfere with the interface layout. That is to say, you can still use the HTML editor to process the page.
E. Client verification.
F. server-side verification.
G. there are a variety of available controllers, including the form-based controllers that provide functions similar to form event processing in VB. This is a series of workflows, where you think it is appropriate, insert your processing 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 make hibernate slim and establish a relationship with the upper layer through spring.

4. Finally, 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, you can look at the example of spring petclinic (Spring + hibernate), there is 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.