Comparison between SpringMVC and Struts2 JavaWeb study notes (XX)

The front end of this time to learn two frames that the two frames are found processing on the presentation layer of the MVC pattern, for ease of understanding these two frames, these two frames together for comparison.

After comparing different I found the following

(1) the difference between the core controller

  1. SpringMVC uses a front-end controllerDispatcherServlet, By its very nature is a Servlet.
  2. Strurs2 framework uses a pre-controllerStrutsPreparedAndExcuteFilter, By its very nature is a Fileter.

(2) Performance

  1. Struts2 is a class-level interceptors, each request will create an instance of Action,Note here that integration issues and Spring, Spring default is singleton.
  2. SpringMVC is based on the method level interceptors, higher performance compared to Struts2. It should be noted,Since the embodiment is a single mode, the global variables must be used with caution. Prevent thread-safety issues.

(3) transmission parameters

  1. Struts2 frame member can be received attribute parameters, a plurality of methods described parameters can be shared, in addition to the data value stack may pass.
  2. SpringMVC between the independent method, by requesting the data acquisition parameters, each parameter between independent method.

(4) interception mechanism

  1. After Struts2 framework can be used in a corresponding interceptor, arranged
  2. I.e., the frame may be employed SpringMVC AOP manner can be realized own interceptor classes.

(5) Ajax interaction

  1. Struts2 interceptor integrates Ajax, you must install the plug-in handling general in the Action or write your own code is integrated into it, is relatively inconvenient to use.
  2. Ajax SpringMVC process is very convenient to use @ResponseBody can receive the request and returns the response data.

Integration (6) and the Spring Framework

  1. Integration with Spring Framework Struts2 more complicated
  2. SpringMVC can seamlessly with Spring.
Published 66 original articles · won praise 26 · views 10000 +

Guess you like

Origin blog.csdn.net/Time__Lc/article/details/93846113