Comparison between SPRING3MVC and Struts2

Source: Internet
Author: User

We used struts2 when using the traditional configuration file method, and did not use the legendary 0 configuration
SPRING3 MVC can be considered already 100% 0 configured (except for configuration Springmvc-servlet.xml)

Compare the differences between STRUS2 and SPRING3 MVC

============================================
The STRUTS2 framework is class-level blocking, creating an action each time a request is made, and then invoking the setter getter method to inject the data in the request
Struts2 is actually dealing with the request through setter getter methods.
In Struts2, an Action object corresponds to a request context

Unlike Spring3 MVC, SPRING3MVC is a method-level intercept that injects the request data into the method based on annotations on the parameters.
In Spring3mvc, a method corresponds to a request context

All right, let's get this sorted out.
Struts2 is a class-level interception, a class that corresponds to a request context,
Springmvc is a method-level interception, a method that corresponds to a request context, and a method that corresponds to a URL
So it's easy to implement restful URLs spring3 MVC from the architecture itself.
And Struts2 's architecture is hard to implement.
Because a method of struts2 action can correspond to a URL
And its class attributes are shared by all methods, which means they cannot be identified by annotations or other means.

===================================
Spring3mvc's approach is essentially independent, and the request response data is exclusive
Request data is obtained through parameters and the processing results are returned to the framework via MODELMAP.
Do not share variables between methods

and Struts2, although the method is also independent, but all of its action variables are shared
This does not affect the program's operation, but it gives us trouble coding to read the program.

====================================
SPRING3 MVC validation is also a bright spot that supports JSR303
The request to process Ajax is more convenient just one annotation @responsebody, then directly return the response text can be

Comparison between SPRING3MVC and 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.