Spring MVC Framework learning Summary

Source: Internet
Author: User

Recently, the spring MVC framework is used in the project. After reading some documents, I have forgotten it.

1. The spring MVC Architecture adopts the command + controller mode. The overall framework is shown in:


The core controller is dispatcherservlet, and the returned view object is the modeandview object.

2. In the case of non-annotation base controller, the Controller class is a subclass of abstractcontrollor. When there is a form, you can inherit the simpleformcontroller class. The onsubmit method is the default method executed after the form is extracted.

3. Spring MVC verification creates a new verification class, which implements the validator interface and overrides the validate method. Generally, the validationutils tool class is called to verify the method; the JSP page contains the incorrect form: Error tag, and the path attribute specifies the domain to be verified. The validate-ref attribute in the bean configuration file indicates the ID of the validation Bean class.

4. Spring MVC interceptor also needs to create a new class that implements handlerintercepteradapter. This class must rewrite the three methods prehandle, posthandle, and aftercompletion. In the bean configuration file, you must add the attribute intercepters-ref in the bean configuration of these interceptors to indicate the ID of the interceptor bean.

5. The controller of spring MVC inherits mulitactioncontroller to process multiple action requests based on different method names in a controller. You only need to specify them in the bean configuration file.

6. Spring MVC Framework supports annotation base controller. Commonly Used annotation includes @ controller, @ requestmapping, @ sessionattribute

The advantages and disadvantages of various mainstream Java Web frameworks are summarized as follows:

Based on these evaluation criteria, Matt then elaborated on the frameworks as follows:

Ajax support

◆ JSF: no built-in Ajax support. icefaces and ajax4jsf must be used.

◆ Stripes: no corresponding class library. Streaming output is supported.

◆ Struts 2: built-in dojo with plug-ins for GWT and JSON

◆ Spring MVC: no corresponding class library. You need to use the DWR and spring MVC extensions.

◆ Tapestry: In tapestry 4.1, there is a built-in dojo

◆ Wicket: supported by dojo and script. aculo. Us

Bookmarks

◆ JSF: You can submit it at will-URL is not even considered

◆ Stripes: Use conventions, but you can ignore them.

◆ Struts 2: There is a namespace concept, which makes it easy to add a page to favorites and return it.

◆ Spring MVC: allow full URL Control

◆ Tapestry: there are still some ugly URLs

◆ Wicket: Mount page/URL

Verify

◆ JSF: the default international information is ugly, but the configuration is simple.

◆ Stripes and Wicket: Verify with Java class-client verification not supported

◆ Struts 2: ognl is used for powerful expression verification. Client verification is supported only when rules are specified on the action.

◆ Spring MVC: allows you to use the public validators-this is a mature solution

◆ Tapestry: robust verification feature-beautiful international information without customization

Testability

◆ Spring MVC and Struts 2: mocks (such as easymock, jmock, and spring MOCKS) can be used for simple tests.

◆ Tapestry: difficult to test, because the page class is abstract and the specific class is simplified.

◆ JSF: The page class can be easily tested. In fact, it is similar to actions in struts 2.

◆ Wicket: wickettester-a powerful solution

◆ Stripes: Includes servlet API mocks and mockroundtrip

Submission and redirection

The easiest way to solve the repeated submission problem is to redirect after submission.

◆ Spring MVC: allows you to add parameters to the Redirection URL.

◆ Stripes, tapestry, and Wicket: Support for "Flash"

◆ Struts 2: a custom solution is required.

◆ JSF: a custom solution is required. It is difficult to add international information to the page bean.

Internationalization

◆ Jstl labels make internationalization easy. There is no uniform standard for how to put internationalized information into the Controller class.

◆ Stripes, spring MVC, and JSF: A resource binding file is used in each region.

◆ Struts 2, tapestry and Wicket: We advocate separating the resource files used by each page/action.

◆ JSF: You need to define the resource binding information on each page.

◆ Tapestry: the label is terrible.

Page Modification

◆ Tiles can be used in struts 2, Spring MVC, and JSF. You need to configure each page.

◆ Sitemesh can be used in all these frameworks (not recommended in JSF, tapestry, or wicket). After the configuration is complete, only a small amount of maintenance is required.

Development Tools

◆ Spring MVC: Spring IDE, but only performs XML verification. It is not a UI/web tool.

◆ Struts 2: Eclipse

◆ Tapestry: spindle, which is very beneficial to the encoding staff

◆ JSF: Many ide support and better performance

◆ Stripes and Wicket: no official tools available

◆ Netbeans currently supports struts *, JSF (+ facelets), tapestry, and Wicket. It does not yet support stripes and spring MVC.



Market Demand

◆ Struts 1: it is still very demanding and widely used.

◆ Spring MVC: more and more popular, but most of them are due to some other features of the Spring framework.

◆ JSF: it soon became popular

◆ Struts 2: gaining ground, but there are few job opportunities

◆ Tapestry: The popularity has increased over the past few years.

◆ Wicket and stripes: Unknown

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.