The difference between struts1.x and struts2.x

Source: Internet
Author: User
Tags garbage collection

The day before yesterday to the internship interview asked Struts1.x and struts2.x difference, a burst of embarrassment said not understand. Come back and learn the difference for the next use! Hey

The difference here is excerpted from: http://www.cnblogs.com/tongzhiyong/archive/2007/02/24/655178.aspx

Because you can't find the original in Struts doc, you can only provide this link version of the

Characteristics

Struts 1

Struts 2

Action types

Struts 1 requires that Action be expanded from an abstract base. One common problem with Struts 1 is that it is oriented to abstract threads rather than interface-oriented threads.

The action for Struts 2 actually has an action interface, together with other interfaces, to 麳 and customize the service. Struts 2 provides a basic interface called Actionsupport 麳 that is commonly used. Although, the Action interface is not required. any use the POJO image of the Execute method can be used as an Action 麳 for Struts 2.

Route process Model

Struts 1 Action is a single case, because only one example 麳 controls all requests. The single strategy creates a certain limit and gives the development an extra hassle. The Action resource must be route or synchronized.

Struts 2 Action For each request is an example of the image, so there is no route security problems. (In fact, the servlet container has a lot of discarded practices for each request, more than one image does not affect garbage collection)

Servlet dependencies

The action type of Struts 1 relies on the servlet API to pass the Execute method when the action is used for HttpServletRequest and httpservletresponse as parameters.

The Action of Struts 2 is not related to the container. The Servlet context is a simple Maps, allowing the Action to be tested independently. The Action of Struts 2 can interview the initial sum response, if needed. However, other scaffolding elements reduce or eliminate the need for direct interviewing of HttpServletRequest or HttpServletResponse.

Easy to detect

The main obstacle to testing Struts 1 is that the Execute method exposes the Servlet API. Third-party expansion, struts test case, provides a set of struts 1 images.

The action of Struts 2 can be used to actually instantiate the action 麳 test, set the attributes, and then adjust the method. The support of dependency injection is also more simple to test.

Accept Input

Struts 1 uses actionform-like 麳 to capture the input. Like an Action, all actionform must expand the base. Because other JavaBean cannot be used as actionform, the developers often create redundant types of 麳 capture inputs. Dynabeans can be used as a substitute for the 麳 of Actionform. But the JavaBean can be redefined by the developers.

The Struts 2 Action is used as input, excluding the need for a second input image. There may be a rich pair of such types that have their own nature. The attributes of the Action can be passed through the tag 麳 interview. Struts 2 also supports actionform forms. The rich image type, which contains the business or domain image, can be used as a 麳 or output pair. The Fuzzy Type Drive feature simplifies the reference of the POJO input to the image.

Express language

Struts 1 whole and JSTL, so it uses JSTL's Express language. The expression language has a basic image movement, but it is relatively weakly set and indexed for the support of the form.

Struts 2 uses JSTL, but the framework also supports a more powerful and more agile expression, called " image Symbol Language" ( OGNL).

Bind the value to the view

Struts 1 uses the standard JSP machine to bind the image to the page context.

Struts 2 uses the "Valuestack" technique for a tag to use without having to link your video to an image's table-type 麳 access value. The Valuestack strategy allows you to reuse the video.

Types of transformation

The actionform of Struts 1 is often String. Struts 1 uses commons-beanutils 麳 types. It is not configured for each of these examples.

Struts 2 uses OGNL 麳 types. The framework contains the converter 麳 for basic and common pairs of images and primitive types.

Experience

Struts 1 supports hand-proof thin to borrow Actionform's validate method, or through the expansion of the public authenticator. It is possible to have different validation contexts 麳 not identical, but not to include an authenticator image.

Struts 2 supports hand-proof thin by validate method and Xwork verification framework. The Xwork verification Framework supports a chain of verification experiences that define the type and seriousness of the nature of the species.

The above bold fields are the difference that I feel very easy to feel.

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.