The difference between Spring and SpringMVC

The difference between Spring and SpringMVC

If you want to clarify the difference between the two, it is difficult to tell without the experience of using these two frameworks. For the sake of simplicity, we will use the well-known Spring and struts frameworks as an example.

 

First of all, for most web developers, the MVC framework, struts, is not unfamiliar. He is the brain of the ssh (Spring+spirngMvc+hibernate) framework. When we talk about the brain, we should understand that it is similar to a workstation that assigns work. , each request will be encapsulated and processed by struts logic, and then handed over to the corresponding processing class for processing. And when springmvc appeared, it had to be said that struts should retire. Although struts is quite powerful, spring can be said to be far behind. However, for our commonly used functions (workstations) spring is already well-deserved. In addition, due to the strong support of spring, and springmvc's use of jar packages depends on spring, more and more developers have chosen springmvc in recent development.
 
Specific written differences:
Spring is an open source framework designed to solve enterprise application development. The functions are as follows. 
Purpose: To solve the complexity of enterprise application development.
Function: Use basic JavaBeans instead of EJB and provide more enterprise application functions.
Scope: Any Java application
In simple terms, Spring is a lightweight Inversion of Control (IoC) and Aspect Oriented (AOP) container framework.
◆ Lightweight - Spring is lightweight in both size and overhead. The complete Spring framework can be distributed in a JAR file of just over 1MB in size. And the processing overhead required by Spring is also trivial. Furthermore, Spring is non-intrusive: typically, objects in a Spring application do not depend on Spring-specific classes.
◆ Inversion of Control - Spring promotes loose coupling through a technique called Inversion of Control (IoC). When IoC is applied, other objects that an object depends on are passed in passively, rather than the object creating or finding dependent objects by itself. You can think of IoC as the opposite of JNDI - instead of the object looking up dependencies from the container, the container proactively passes dependencies to it when the object is initialized without waiting for the object to request it.
◆Aspect-oriented - Spring provides rich support for aspect-oriented programming, allowing cohesive development by separating the application's business logic from system-level services (such as auditing and transaction management). Application objects do only what they are supposed to do - complete business logic - nothing more. They are not responsible for (or even aware of) other system-level concerns, such as logging or transaction support.
Containers - Spring contains and manages the configuration and lifecycle of application objects, in the sense that it is a container where you can configure how each of your beans is created - based on a configurable prototype, your Beans can create a single instance or spawn a new one each time they are needed - and how they relate to each other. However, Spring should not be confused with traditional heavyweight EJB containers, which are often bulky and bulky and difficult to use.
◆Framework - Spring can configure and combine simple components into complex applications. In Spring, application objects are composed declaratively, typically in an XML file. Spring also provides many basic functions (transaction management, persistence framework integration, etc.), leaving the development of application logic to you.
All of these features of Spring enable you to write cleaner, more manageable, and easier-to-test code. They also provide basic support for various modules in Spring.

Spring's two cores, AOP and IOC, can be used alone in any application, including integration with MVC frameworks such as Struts and ORM frameworks such as Hibernate. At present, many companies use Spring + Struts(2) + Hibernate for so-called lightweight development.
Spring MVC is an MVC framework. I personally think that Spring MVC annotation development is more convenient than Struts2, and can directly replace the above Struts (of course, Struts, as a very mature MVC, still feels a little stronger than Spring in function, but Spring MVC has enough). Of course, the execution efficiency of spring mvc is higher than that of struts, because the value stack of struts affects the efficiency.

spring mvc is similar to an MVC open framework of struts.
 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326125466&siteId=291194637