The difference between Spring, SPRINGMVC, Struts2

Source: Internet
Author: User

One, the difference between spring and SPRINGMVC:

Spring is an open source framework that is designed to address enterprise application development with the following features:

Function: Use basic JavaBean instead of EJB, and provide more enterprise application function

Scope: Any Java application spring is a lightweight control inversion (IoC) and facet-oriented (AOP) container framework.

1. Lightweight-Spring is lightweight, both in terms of size and overhead. The full spring framework can be published in a jar file with a size of more than 1MB. and the processing overhead required by spring is negligible. In addition

Spring is non-intrusive: Typically, objects in spring applications do not depend on a particular class of spring.

2. Control reversal--spring facilitates loose coupling through a technique called inversion of Control (IoC). When an IOC is applied, other objects that an object relies on are passed in passively, rather than being created by the object itself or

To find dependent objects. You can think of the IOC as opposed to Jndi--not the object looking for dependencies from the container, but the container actively passing the dependency to it when the object is initialized without waiting for the object to be requested.

3. Aspect-oriented--spring provides rich support for aspect-oriented programming, allowing for the development of cohesion through the separation of application business logic with system-level services such as auditing (auditing) and transaction (transaction) management.

The Application object only implements what they should do-complete the business logic-that's all. They are not responsible (or even conscious) for other system-level concerns, such as log or transaction support.

4, Container--spring contains and manages the configuration and life cycle of the Application object, in this sense it is a container, you can configure how each of your beans is created-based on a configurable prototype (prototype), your

Beans can create a separate instance or generate a new instance each time they need it--and how they relate to each other. However, spring should not be confused with traditional heavy-weight ejb containers, which are often large

With bulky, hard-to-use.

5, Frame--spring can be a simple component configuration, the combination of complex applications. In spring, application objects are combined declaratively, typically in an XML file. Spring also provides a number of basic functions (transaction tube

Persistence framework integration, etc.), leaving the development of application logic to you. All of these features of spring enable you to write cleaner, more manageable, and easier-to-test code. They are also for various modules in spring

For the basic support.

Spring's two core AOP and IOC can be used for any application, including the integration of an ORM framework such as the MVC framework such as struts and hibernate, which many companies now call lightweight development

Spring + Struts (2) +hibernate.

Spring MVC is an MVC framework that personally feels that spring MVC annotation-style development is easier than Struts2, and can be used directly instead of struts above (and of course struts as a very mature MVC, functionally or

A bit stronger than spring, but spring MVC is good enough). Of course, Spring MVC performs more efficiently than struts because the value stack of struts affects efficiency.

Spring MVC is similar to the one of struts's MVC open frames, which are all part of the spring,spring MVC need to have spring's scaffolding as a support to run.

Two, spring and Struts2 difference:

Struts2 is an interceptor stack, which is a series of interceptors. Handling user requests, OGNL usage, form validation, and so on are the default interceptors that work.

Spring interceptors, mainly in the aspect of AOP transaction management, as well as the display of some errors or unusual logs are also implemented by configuring spring's log Interceptor.

Three, the difference between STRINGMVC and Struts2:

1, Struts2 is a class-level interception, a class corresponding to a request context, SPRINGMVC is a method-level interception, a method corresponding to a request context, and the method at the same time with a URL corresponding, so that the schema itself

SPRINGMVC is easy to implement restful URLs, and Struts2 's architecture is laborious, because a method of action in Struts2 can correspond to a URL, and its class properties are shared by all methods, which cannot be used with annotations or other

Way to identify the method to which it belongs.

2, the Springmvc method is basically independent, the request response data, requests the data through the parameter acquisition, the processing result passes through the modelmap to the frame, the method does not share the variable, but Struts2 does more than

More chaotic, although the method is also independent, but all of its action variables are shared, which does not affect the program to run, but it gives us the trouble of coding the program, each time a request to create an action, an action object to

should be a request context.

3, Struts2 need to package for each request, the request,session and other servlet life cycle variables encapsulated into a map, for each action to use, and to ensure thread safety, so in principle, it is more

Cost of memory.

4, the Interceptor implementation mechanism, STRUTS2 has its own interceptor mechanism, SPRINGMVC with the independent AOP way, so that Struts2 configuration file volume is still larger than SPRINGMVC.

5. SPRINGMVC's entrance is the servlet, and Struts2 is the filter (it should be noted here that the filter and servlet are different.) Previously thought that filter was a special type of servlet, which led to a different mechanism,

The difference between a servlet and a filter.

6, SPRINGMVC integration of Ajax, the use of very convenient, just one annotation @responsebody can be implemented, and then directly return the response text, and STRUTS2 Interceptor integrated Ajax, in action is generally necessary to

Installing plug-ins or writing your own code into it is relatively inconvenient to use.

7, SPRINGMVC verification support JSR303, handling relatively more flexible and convenient, and Struts2 verification is more cumbersome, feel too upset.

8, SPRINGMVC and spring are seamless. The management and security of this project is also higher than Struts2 (of course Struts2 can also be springmvc the same effect through different directory structures and related configurations, but XML configuration is required

A lot of places).

9, design ideas, Struts2 more in line with OOP programming ideas, SPRINGMVC more cautious, extended on the servlet.

10, SPRINGMVC development efficiency and performance is higher than Struts2.

11, SPRINGMVC can be considered to have 100% 0 configuration.

The difference between Spring, SPRINGMVC, Struts2

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.