Advantages and disadvantages of SPRINGMVC and struts+hibernate+spring

Source: Internet
Author: User

SPRINGMVC:

The Spring framework is highly configurable and includes a variety of view technologies, such as JavaServer Pages (JSP) technology, Velocity, Tiles, IText, and POI. The Spring MVC framework does not know which view to use, so you can choose the view autonomously. Spring MVC separates the roles of controllers, model objects, dispatchers, and handler objects, and this separation makes them easier to customize. System Framework SPRINGMVC MyBatis Bootstrap HTML5 shiro maven SSM

Struts+spring+hiberante:

The system of the SSH framework is divided into four layers: the presentation layer, the business logic layer, the data persistence layer and the Domain module layer, to help the developers build a clear, reusable and maintainable Web application in a short period of time. It uses struts as the overall infrastructure of the system, is responsible for the separation of MVC, controls the business jump in the model part of the Struts framework, supports the persistence layer with the Hibernate framework, manages the spring, manages struts and hibernate. By using object-oriented analysis method, we propose some models, implement these models as basic Java objects, and then write the basic DAO (Data Access Objects) interface, and give the DAO implementation of Hibernate. The DAO class implemented by the hibernate architecture implements conversion and access between Java classes and databases, and finally manages struts and hibernate with spring.

Summary of advantages and disadvantages:

1, based on annotations, stuts2 although there are annotations but relatively slow, no one use more time is in the form of XML
2, can integrate with other spring technology such as webflow, etc.
3, GET request and Session object is relatively simple, directly when the parameter value is passed, and Struts2 also need to get through the Servletactioncontext object
4, the verification is also relatively simple, through the jsr-303 can be achieved, without writing other code, and Struts2 is written actionname-validation.xml implementation of the
The advantages of saying struts2:
1, do not have to focus on whether the client is a get commit or a set commit, SPRINGMVC's address map annotation method is a must to be concerned
2, automatic packaging objects, SPRINGMVC, is encapsulated in the model can only be in, so you will see the input box number type has 0 or 0.0 options
3, custom result types, such as XML and SPRINGMVC can only return modelandview, or do not return
4, decoupling the view from the result, because Struts2 returns a string, only through struts.xml to know the specific JSP, or HTML, and SPRINGMVC can only explicitly return Modelandview
5,STRUTS2 does not require a special Chinese filter, and SPRINGMVC3 needs to be configured
They are much the same for labels, but when it comes to automatic assembly, the form form of the SPRINGMNC must be used, while the struts2 is not, and the other functions are similar, but efficiently, the SPRINGMVC label is faster than Struts2 because, Struts2 the heap and stack through request, so the efficiency is reduced, I recommend or use JSP tag not only easy to expand and, efficiency is good
Again application scenario: If all are successful after jumping a page of that both can, and if it is other type, then Struts2 is a good choice, for example, Extjs4.0 Add object Automatic assembly Struts2 can be achieved, but SPRINGMVC not, Unless you like a lot of request.getparamter ()

6, Performance:

Spring will be a little faster than struts. Spring MVC is a method-based design, and Sturts is class-based, each time a request is made with an action, each action is injected into the attribute, and spring is based on a method that is finer grained, but be careful to hold the same data as the servlet. Spring3mvc is a method-level intercept that, after intercepting the method, injects the request data into the parameter according to the annotations on the parameters, and in Spring3mvc, a method corresponds to a request context. The STRUTS2 framework is class-level blocking, creating an action each time a request is made, and then invoking the Settergetter method to inject the data from the request; Struts2 actually deals with the request through setter getter methods, And SPRINGMVC does not use setter getter method; in Struts2, an Action object corresponds to a request context.

To achieve restful:

Springmvc is a method-level intercept, a method that corresponds to a request context, and a method that corresponds to a URL, so it is easy to implement a restful URL spring3 mvc from the schema itself. STRUTS2 is class-level interception, a class corresponds to a request context, and implementing Restfulurl is laborious because a method of struts2 action can correspond to a URL, and its class properties are shared by all methods. It is also not possible to identify the method that it belongs to by annotations or other means.

Data sharing:

Struts is a parameter that can be accepted with attributes when it accepts parameters, which means that the parameters are shared by multiple methods.

The SPRING3 MVC approach is essentially independent of the request response data, requesting the data to be fetched through the parameters, and the results are returned by Modelmap to the framework method without sharing the variables

Summary:

Actually with what technology, this really does not have the rigid request, some people think that struts is easy to use, some people feel springmvc advanced. In general, the functions implemented are broadly consistent. Sometimes the architect has been using struts, for the stability of the project has been used, and some advanced molecules always like in the project common sense of new technology, but also promote the development of this technology. In the case of struts and SPRINGMVC, it is the framework of the controller layer, the function is to receive request requests, the middle call business logic code, and finally return to reponse response, do not deliberately away from SSH, do not blindly pursue spring MVC. In short, the right is the best.

Advantages and disadvantages of SPRINGMVC and struts+hibernate+spring

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.