Comparison of Spring MVC and Struts2 (II.)

Source: Internet
Author: User

1. Spring MVC's Controller+command object mode is more secure thanSTRUTS2 's act ion mode. In Struts2, automatic data binding occurs on the Action object. Thus, any propertyin the act ion class that has a set method may be overwritten by the parameters of the HTTP request, whichcan create a security risk if you are not careful when designing the act ion class. For example, an authentication scheme might rely on aproperty of Act ion, such as role, to determine whether a user haspermission to access the Act ion. In this way, a malicious user can overwrite the settings of the role property by the Action itself by including a role parameter in the request parameter.
In spring MVC, Controller and command object are two separate classes, automatic data binding occurs only on command object, and there is no effect on the controller, there is no problem.
2. The Action class of Struts 2 is inherently thread insecure and cannot be created using singleton mode. In my opinion, this is more ugly. In particular, the Action, which handles complex logic, can be expensive to create a new object instance at a time. Spring MVC's Command object is basically Pojo, and the cost of creating an instance is very low.
3. The JSP tags of Struts 2 use OGNL as the expression language. I personally feel that this language is too powerful, especially for direct accessto the act ion itself, which can easily be abused to repeat the mistakes of the past jsp<%%> tags.
Of course, Struts 2 also has many features that are worth the spring, suchas redirect-act ion, support for namespace, and so on. In particular, the latest version of Struts 2 's underlying framework xwork 2.0BETA3 has supported annotation-based validation, and this spring should be followed up as soon as possible.
But I still think spring MVC is better.

Below is a list of my evaluations of these two excellent frameworks, please help to judge:

------------------------SPRINGMVC-----Struts2.0 (WEBWORK2)--------------winner
Development efficiency----------------5-------------? ---------------------------------?

Operating efficiency----------------5-------------4 (Action Non-singleton)------------------SPRINGMVC

Learning Cost----------------4-------------3 (colleague Response learning curve is steep)--------Springmvc

Integrated with spring------------5 (seamless integration) 4----------------------------------SPRINGMVC
Degree of difficulty

Validator Integrated-----------4 (commons)--5----------------------------------Struts2.0

Ajax Integration----------------4-------------5 (Rich tag support)-----------------Struts2.0

Testability----------------5-------------5----------------------------------Draw

From the actual development results, in 4 projects with the spring2.5 mvc,2 projects with struts2, found that recruitment, are struts1,struts2 job seekers, and spring MVC is training, but the learning curve is really low, after the structure of a good, Most people can adapt quickly and develop quickly. The development of STRUTS2, the previous 2 projects, are just someone else's architecture, actually do functional testing and performance testing, problems piled up. STRUTS2 data binding is simply a disaster, and novices often mess up the parameters.

Comparison of Spring MVC and Struts2 (ii)

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.