Spring MVC framework learning

1. Introduction to spirng

Spring is an open source framework created by Rod Johnson. It was created to address the complexities of enterprise application development. Spring uses basic JavaBeans to do things that were previously only possible with EJBs. However, Spring's uses are not limited to server-side development. Any Java application can benefit from Spring in terms of simplicity, testability, and loose coupling.

Second, the working principle of spring (MVC)

       1. springmvc asks all requests to be submitted to DispatcherServlet, which entrusts other modules of the application system to be responsible for the real processing of requests. 

  2. DispatcherServlet queries one or more HandlerMappings and finds the Controller that processes the request. 
  3. DispatcherServlet please submit the request to the target Controller  4. Controller
  will return a ModelAndView after business logic processing 
  5. Dispathcher queries one or more ViewResolver view resolvers , Find the view object specified by the ModelAndView object 
  6. The view object is responsible for rendering and returning it to the client.

3. The role of spring

        AOP lets developers create non-behavioral concerns, called cross-cutting concerns, and insert them into application code. With AOP, common services (such as logging, persistence, transactions, etc.) can be decomposed into aspects and applied to domain objects without increasing the complexity of the object model of the domain objects. 

  IOC allows the creation of an application environment in which objects can be constructed and then passed to those objects their collaborating objects. As the word inversion suggests, IOC is like JNDI in reverse. Instead of using a bunch of abstract factories, service locators, singletons, and straight constructions, each object is constructed with its collaborating objects. So the container manages the collaborator. 
  Even though Spring is an AOP framework, it is also an IOC container. The best thing about Spring is that it helps you replace objects. With Spring, just add dependencies (collaboration objects) with JavaBean properties and configuration files. Collaborating objects with similar interfaces can then be easily replaced when needed. 
  The Spring Framework is a layered architecture consisting of 7 well-defined modules. Spring modules are built on top of the core container, which defines how beans are created, configured, and managed, as shown in Figure 1. 
  Each module (or component) that makes up the Spring Framework can exist alone, or be implemented in conjunction with one or more other modules. The functions of each module are as follows: 
  Core container: The core container provides the basic functions of the Spring framework. The main component of the core container is the BeanFactory, which is an implementation of the factory pattern. BeanFactory uses the Inversion of Control (IOC) pattern to separate the application's configuration and dependency specification from the actual application code. 
  Spring Context: A Spring context is a configuration file that provides context information to the Spring framework. The Spring context includes enterprise services such as JNDI, EJB, email, internationalization, validation and scheduling functions. 
  Spring AOP: The Spring AOP module integrates aspect-oriented programming capabilities directly into the Spring framework through configuration management features. Therefore, any object managed by the Spring Framework can easily be made AOP-aware. The Spring AOP module provides transaction management services for objects in Spring-based applications. By using Spring AOP, declarative transaction management can be integrated into applications without relying on EJB components. 
  Spring DAO: The JDBC DAO abstraction layer provides a meaningful exception hierarchy that can be used to manage exception handling and error messages thrown by different database vendors. The exception hierarchy simplifies error handling and greatly reduces the amount of exception code that needs to be written (such as opening and closing connections). SpringDAO's JDBC-oriented exceptions follow the generic DAO exception hierarchy. 
  Spring ORM: The Spring framework plugs into several ORM frameworks to provide the ORM's object-relational tools, including JDO, Hibernate, and iBatis SQL Map. All follow Spring's generic transaction and DAO exception hierarchy. 
  Spring Web Module: The Web Context Module builds on the Application Context Module and provides context for web-based applications. So, Spring framework supports integration with Jakarta Struts. The web module also simplifies handling multipart requests and binding request parameters to domain objects. 
  Spring MVC Framework: The MVC framework is a full-featured MVC implementation for building web applications. Through the strategy interface, the MVC framework becomes highly configurable, and MVC accommodates a number of view technologies, including JSP, Velocity, Tiles, iText, and POI. 
  Features of the Spring Framework can be used in any J2EE server, and most features also apply to unmanaged environments. The core point of Spring is to support reusable business and data access objects that are not tied to specific J2EE services. There is no doubt that such objects can be reused between different J2EE environments (Web or EJB), stand-alone applications, and test environments.

Four, spring rack package catalog description

      The aspectj directory contains the source code and test program files for using aspectj under the Spring framework. 

     Aspectj is the earliest application framework that provides AOP in java. 
     The dist directory is the release package of Spring. The release package will be explained in detail below. 
     Under the docs directory are related documents, including the javadoc of Spring api, reference guide, Spring's tag library usage files, and Spring MVC's MVC-step-by-step explanations and examples. Both are well documented and worth looking into. 

   The lib directory is the third-party open source package that Spring depends on. 

     The mock directory is the mock source program for Spring auxiliary application testing. 
     The samples directory is the sample source program of Spring and the sample configuration of the simple webapp sample framework. It is worth learning about jpetstore and petclinic. Of course, other countries, imagedb, tiles-example can also be used for reference. 
     The src directory is the source program of Spring. 
     Spring's unit test source program in the test directory. 
     Under the tiger directory are the source programs and test programs for using java 1.5 in the Spring framework. Tiger is the development codename of the JDK 1.5 version. 

5. Detailed explanation of the working function of the spring rack package

       spring.jar is a single jar that contains the complete distribution module. But mock.jar, aspects.jar, spring-portlet.jar, and spring-hibernate2.jar are not included. 

     spring-src.zip is all the source code compressed package. 
     In addition to the spring.jar file, Spring also includes 21 other independent jar packages, each of which contains the corresponding Spring components. Users can choose and combine their own jar packages according to their own needs without introducing all the classes of the entire spring.jar. document. 
    spring-core.jar (required) 
     This jar file contains the basic core utility classes of the Spring Framework. The classes in this package must be used by other Spring components, which are the basic core of other components. Of course, you can also use these tool classes in your own application system. 
External dependency Commons Logging, (Log4J). 
spring-beans.jar (required) 
This jar file is used by all applications. It contains all classes related to accessing configuration files, creating and managing beans, and performing Inversion of Control / Dependency Injection (IoC/DI) operations. If the application only needs basic IoC/DI support, it is enough to import the spring-core.jar and spring-beans.jar files. 
External dependencies spring-core, (CGLIB). 

spring-aop.jar (required) 
This jar file contains the classes and source-level metadata support needed to use Spring's AOP features in an application. Use AOP-based Spring features, such as Declarative Transaction Management, and include this jar in your application. 
External dependencies spring-core, (spring-beans, AOP Alliance, CGLIB, Commons Attributes). 

spring-context.jar (required) 
This jar file provides a number of extensions to the Spring core. You can find all the classes required to use the Spring ApplicationContext feature, all the classes required by JDNI, the instrumentation components, and related classes for validation. 
External dependencies spring-beans, (spring-aop). 

spring-dao.jar (required) 
This jar file contains all classes for data access by Spring DAO and Spring Transaction. In order to use declarative transaction support, you also need to include spring-aop.jar in your application. 
External dependencies spring-core, (spring-aop, spring-context, JTA API). 

spring-jdbc.jar (required) 
This jar file contains all the classes that encapsulate Spring's JDBC data access. 
External dependencies spring-beans, spring-dao. 

spring-support.jar (required) 
This jar file contains classes that support UI templates (Velocity, FreeMarker, JasperReports), mail services, scripting services (JRuby), Cache (EHCache), and task scheduling (uartz). 
External dependencies spring-context, (spring-jdbc, Velocity, FreeMarker, JasperReports, BSH, Groovy, JRuby, Quartz, EHCache) 

spring-web.jar (required) 
This jar file contains all the tools needed for Web application development when using the Spring framework Required core classes, including classes for automatically loading Web Application Context features, Struts and JSF integration classes, file upload support classes, Filter classes, and a large number of tool auxiliary classes. 
External dependencies spring-context, Servlet API, (JSP API, JSTL, Commons FileUpload, COS). 

spring-webmvc.jar 
This jar file contains all classes related to Spring MVC framework. Includes framework Servlets, Web MVC framework, controller and view support. Of course, if your application uses a standalone MVC framework, you don't need any of the classes in this JAR file. 
External dependencies spring-web, (spring-support, Tiles, iText, POI). 

spring-portlet.jar 
A Spring MVC-like framework implemented by spring itself. Includes an MVC framework and controllers. 
External dependencies spring-web, Portlet API, (spring-webmvc). 

spring-struts.jar 
Struts framework support, can be more convenient and easier to integrate Struts framework. 
External dependencies spring-web, Struts. 

spring-remoting.jar 
This jar file contains classes that support EJB, remote call Remoting (RMI, Hessian, Burlap, Http Invoker, JAX-RPC). 
External dependencies spring-aop, (spring-context, spring-web, Hessian, Burlap, JAX-RPC, EJB API). 

The spring-jmx.jar 
jar package provides support classes for JMX 1.0/1.2. 
External dependencies spring-beans, spring-aop, JMX API. 

The spring-jms.jar 
jar package provides support classes for JMS 1.0.2/1.1. 
External dependencies spring-beans, spring-dao, JMS API. 

spring-jca.jar 
support for JCA 1.0. 
External dependencies spring-beans, spring-dao, JCA API. 

spring-jdo.jar 
support for JDO 1.0/2.0. 
External dependencies spring-jdbc, JDO API, (spring-web). 

spring-jpa.jar 
for JPA 1.0 support. 
External dependencies spring-jdbc, JPA API, (spring-web). 

The support of spring-hibernate2.jar 
for Hibernate 2.1 has been deprecated. 
External dependencies spring-jdbc, Hibernate2, (spring-web). 

spring-hibernate3.jar 
support for Hibernate 3.0/3.1/3.2. 
External dependencies spring-jdbc, Hibernate3, (spring-web). 

spring-toplink.jar 
support for TopLink framework. 
External dependencies spring-jdbc, TopLink. 

spring-ibatis.jar 
support for iBATIS SQL Maps. 
External dependencies spring-jdbc, iBATIS SQL Maps. 

The other two packages. 

spring-mock.jar 
This jar file contains a complete set of Spring mock classes to assist application testing. The Spring test suite uses many of these mock classes to make testing easier. Mocking the HttpServletRequest and HttpServletResponse classes is handy in unit testing Web applications. And provides support for JUnit. 
Externally depends on spring-core. 

spring-aspects.jar 
provides AspectJ support so that aspect-oriented functionality can be easily integrated into IDEs such as Eclipse AJDT. 
External dependencies. 

WEAVER JARS (dist/weavers) instructions. 

spring-agent.jar 
Spring's InstrumentationSavingAgent (InstrumentationLoadTimeWeaver), a device agent package, can refer to the Instrumentation function of JDK1.5 for more information. 
External dependencies none (for use at JVM startup: "-javaagent:spring-agent.jar"). 

spring-tomcat-weaver.jar 
extends Tomcat's ClassLoader so that it can use the instrumentation (device) class. 
External dependencies none (for deployment into Tomcat's "server/lib" directory).

Guess you like

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