1, Struts2 is class-level interception, a class corresponding to a request context, SPRINGMVC is a method-level interception, a method corresponding to a request context, and the method at the same time with a URL corresponding to the So it's easy to implement restful URLs from the architecture itself, and Struts2 's architecture is SPRINGMVC because a method of action in Struts2 can correspond to a URL, and its class properties are shared by all methods. It is also not possible to identify the method that it belongs to by annotations or other means.
2, from the above reasons, Springmvc method is basically independent of the request response data, requests for data through parameters, processing results through the MODELMAP to the framework, the method does not share variables, and Struts2 to make a relatively chaotic, Although the method is also independent, but all of its action variables are shared, which does not affect the program run, but it gives us the trouble of coding to read the program, each time a request to create an action, an action object corresponding to a request context.
3. Because Struts2 needs to be encapsulated for each request, the variables of the servlet life cycle such as request,session are encapsulated into a single map, supplied to each action, and thread-safe, so in principle, it is more memory-intensive.
4, the Interceptor implementation mechanism, STRUTS2 has its own interceptor mechanism, SPRINGMVC with the independent AOP way, so that Struts2 configuration file volume is still larger than SPRINGMVC.
5. SPRINGMVC's entrance is the servlet, and Struts2 is the filter (it should be noted here that the filter and servlet are different.) It was thought that filter was a special kind of servlet, which led to a different mechanism between the two, which involved the difference between servlet and filter.
6, SPRINGMVC integration of Ajax, the use of very convenient, just a note @responsebody can be implemented, and then directly return the response text, and STRUTS2 interceptor integrated Ajax, In action, it is generally necessary to install plug-ins or write code to integrate them, it is relatively inconvenient to use.
7, SPRINGMVC verification support JSR303, handling relatively more flexible and convenient, and Struts2 verification is more cumbersome, feel too upset.
8. Spring MVC and Spring are seamless. From this project management and security is also higher than Struts2 (of course Struts2 can also be done through different directory structure and related configuration to achieve springmvc the same effect, but need XML configuration of a lot of places).
9, design ideas, Struts2 more in line with OOP programming ideas, SPRINGMVC more cautious, extended on the servlet.
10, SPRINGMVC development efficiency and performance is higher than Struts2.
11, SPRINGMVC can be considered to have 100% 0 configuration.
Comparison of Struts2 and SPRINGMVC