Springmvc and Struts2 difference and comparison summary

Source: Internet
Author: User

1. STRUTS2 is class-level interception, a class corresponds to a request context, SPRINGMVC is a method-level intercept, a method corresponds to a request context, and the method corresponds to a URL, So it's easy to implement restful URLs from the architecture itself, and Struts2 's architecture is SPRINGMVC because a method of action in Struts2 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.

2, from the above reasons, Springmvc method is basically independent of the request response data, requests for data through parameters, processing results passed modelmap to the framework, the method does not share variables, And Struts2 do is more chaotic, although the method is also independent, but all of its action variables are shared, this will not affect the program to run, but give us the code to read the program caused trouble, each time a request to create an action, An Action object corresponds to a request context.
3, since Struts2 needs to be encapsulated for each request, the variables of the servlet life cycle such as request,session are encapsulated into a map, supplied for each action, and thread-safe, so in principle, is more memory-intensive.

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. The SPRINGMVC entrance is the servlet, and Struts2 is the filter (it is noted here that the filter and servlet are different.) It was thought that filter was a special kind of servlet, which led to a different mechanism between the two, which involved the difference between servlet and filter.

6. SPRINGMVC integrates Ajax, is very convenient to use, just one annotation @responsebody can be implemented, and then directly return to the response text, and STRUTS2 interceptor integrated Ajax, In action, it is generally necessary to install plug-ins or write code to integrate them, it is relatively inconvenient to use.

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

8. Spring MVC and Spring are seamless. From this project management and security is also higher than Struts2 (of course Struts2 can also be done through different directory structure and related configuration to achieve springmvc the same effect, but need XML configuration of 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 already 100% 0 configured.

Springmvc and Struts2 difference and comparison summary

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.