Turn from
http://flyingsnail.blog.51cto.com/5341669/1282359
Look at the links in the better, with emphasis on labeling.
Only recently discovered that spring also can implement MVC, so looked for the relevant introduction on the net:
The original purpose of the frame is relatively simple---springmvc support rest, niche to restful URL heartily like
No need to know the use of the discovery of development efficiency is really higher than struts2
We used struts2 when using the traditional configuration file method, and did not use the legendary 0 configuration
SPRING3 MVC can be considered already 100% 0 configured (except for configuration Springmvc-servlet.xml)
Compare the differences between STRUS2 and SPRING3 MVC
============================================
The STRUTS2 framework is class-level blocking, creating an action each time a request is made, and then invoking the setter getter method to inject the data in the request
Struts2 is actually dealing with the request through setter getter methods.
In Struts2, an Action object corresponds to a request context
Unlike Spring3 MVC, SPRING3MVC is a method-level intercept,
After intercepting the method, the request data is injected according to the annotations on the parameters.
In Spring3mvc, a method corresponds to a request context
All right, let's get this sorted out.
Struts2 is a class-level interception, a class that corresponds to a request context,
Springmvc is a method-level interception, a method that corresponds to a request context, and a method that corresponds to a URL
So it's easy to implement restful URLs spring3 MVC from the architecture itself.
And Struts2 's architecture is hard to implement.
Because a method of struts2 action can correspond to a URL
And its class attributes are shared by all methods, which means they cannot be identified by annotations or other means.
===================================
Spring3mvc's approach is essentially independent, and the request response data is exclusive
Request data is obtained through parameters and the processing results are returned to the framework via Modelmap .
Do not share variables between methods
and Struts2, although the method is also independent, but all of its action variables are shared
This does not affect the program's operation, but it gives us trouble coding to read the program.
====================================
Spring MVC Benefits:
Spring MVC through the policy interface, the spring framework is highly configurable and includes a variety of view technologies, such as JavaServer Pages (JSP) technology, Velocity, Tiles, IText, and POI. The Spring MVC framework does not know which view to use, so it does not force you to use only JSP technology.
It is a typical textbook-style MVC architecture, unlike struts and so on is a variant or not entirely based on the framework of the MVC system, for beginners or people who want to know about MVC I think spring is the best, its implementation is the textbook! Second, it is a pure servlet system like tapestry, which is the advantage that struts does not have compared to tapestry. And the framework itself has code, and it doesn't look too laborious to be simpler and more understandable.
1, Spring3 MVC Learning difficulty is less than the struts2,struts2 of unnecessary functions too much. Oh, of course this is not the deciding factor.
2, Spring3 MVC is easy to write a good performance program, Struts2 to be careful to write good performance program (refers to the MVC part)
3, Spring3 MVC flexibility is you can not imagine, Spring's extensibility is legendary, Spring3 MVC certainly will not lag behind, not because of the use of the MVC framework and feel any restrictions.
====================================
SPRING3 MVC validation is also a bright spot that supports JSR303
The request to process Ajax is more convenient just one annotation @responsebody, then directly return the response text can be
Attach a piece of code:
@RequestMapping (value= "/whitelists")
Public String Index (modelmap map) {
Account account = Accountmanager.getbydigitid (Securitycontextholder.get (). Getdigitid ());
list<group> grouplist = Groupmanager.findallgroup (Account.getid ());
Map.put ("account", account);
Map.put ("Grouplist", grouplist);
return "/group/group-index";
}
@ResponseBody Ajax Response
@RequestMapping (value= "/whitelist/{whitelistid}/del")
@ResponseBody
Public String Delete (@PathVariable Integer whitelistid) {
Whitelistmanager.deletewhitelist (Whitelistid);
Return "Success";
}
What is the difference between Struts and SPRINGMVC?
Many people learn ssh and know that struts is the first to be used to control the performance layer, but struts already have MVC why is there spring MVC?
So I looked at a little bit of information and summed up their differences:
1. Mechanism. The entrance to Spring MVC is the servlet, and struts is the filter (it is noted here that the filter and servlet are different.) Previously thought that filter was a special type of servlet, which led to a different mechanism,
This involves the difference between servlet and filter, and my other blogs specialize in writing the difference between servlet and filter.
2. Performance. Spring will be a little faster than struts. Spring MVC is a method-based design, and Sturts is class-based, each time a request is made with an action, each action is injected into the attribute, and spring is based on a method that is finer grained, but be careful to hold the same data as the servlet.
3. Parameter passing. Struts is a parameter that can be accepted with attributes when it accepts parameters, which means that the parameters are shared by multiple methods.
4. Design ideas. Struts is more consistent with OOP programming ideas, and spring is more cautious, extending on the servlet,
5.intercepter implementation mechanism. Struts has its own interceptor mechanism, and spring MVC uses an independent AOP approach. This results in struts having a larger profile than spring MVC, although the struts configuration can be inherited, so I think the use of spring MVC is more concise.
The difference between struts ' MVC and Spring's MVC