SpringIOC consistent with the interface and achieve the most basic of IOC container BeanFactory,
Spring is also a core module SpringAOP
SpringMVC around DispatcherServlet, MVC can be implemented to complete the front-end design WEB
SpringJDBC / Spring ORM Spring package made of JDBC, provides the basic operating method JDBCTemplate as a template, a package, in addition to providing the operation target RDBMS, object-oriented method of using JDBC. Meanwhile, Spring ORM package also provides many of the tools, and the like such as Hibernate
Spring AOP achieve a transaction through declarative transaction management
When Spirng remote call application distributed deployment, by Spring package for a variety of communications applications to achieve shielding and call details
Spring Spring application can make more convenient and simple to accommodate third-party technology to achieve through this module
2.Spring frame acquired connection pool four ways
DBCP data source
C3P0 data sources
spring implementation class data source (the DriverManagerDataSource)
Get JNDI datasource
3.spring three kinds of injection method
Constructor injection
setter injection
Interface injection
4.spring transaction management
Strong programmatic transaction management flexibility, but difficult to maintain
Declarative transaction management (using) the separation of business code and transaction management, just use annotations and XML configuration to manage transactions, realized through AOP
@Transactional annotation method can only be applied to public visibility
Recommended @Transactional annotation on a specific class (or a class method), rather than the interface
By default, if the database operation method annotated happen in abnormality, all database operations will rollback runtime; if abnormal occurrence of abnormality is checked, the default database operations will still submit the case
The role of @Transactional annotation can be propagated to subclasses, that is, if the parent class standard subclass would not mark up. But upside down to die
In the same class, plus a no annotated notes of the call, the transaction is called method will not take effect because the internal call does not call the agent section of logic, if you want to call section can be considered AopContext.currentProxy () this way.
5.spring transaction propagation behavior
PROPAGATION_REQUIRED (default) if no transaction creates a new transaction, if there is already a transaction, added to this transaction
PROPAGATION_SUPPORTS support the current transaction, if no transaction is executed in a non-transactional way
PROPAGATION_MANDATORY use the current transaction, if no transaction, throw an exception
PROPAGATION_REQUIRES_NEW New Transaction, if the current transaction exists, the current transaction suspension
PROPAGATION_NOT_SUPPORTED perform operations to a non-transactional way, if the current transaction exists, put the current transaction pending
PROPAGATION_NEVER to perform non-transactional way, if the current transaction exists, an exception is thrown
PROPAGATION_NESTED if the current transaction exists, it is executed within nested transactions. If no transaction is performed with a similar operation PROPAGATION_REQUIRED
6. @ Resource and difference of @Autowire
@Autowired default by type fitting (This comment is of spring metal industry), default claim dependent objects must be present, if you want to allow null values, can set its required property is false, such as: @Autowired (required = false) If we want to use the name of the assembly can be carried out using a combination of @Qualifier comment
@Resource is JDK1.6 support annotations, the default assembled by name, the name can be specified by the name attribute, if you do not specify the name attribute, when the notes written on the field, take the default field names, find by name, if you write notes on the setter method takes a default attribute name assembled. When that matches the name can not be found when assembled in accordance with the type of bean. However, note that if the name attribute if specified, will only be assembled by name.
7.SpringMVC workflow
⑴ user sends a request to the server, the request is captured Servelt DispatcherServlet Spring front control;
⑵DispatcherServlet request URL parsing to obtain the requested resource identifier (URI). According to this then the URI, access to all relevant call HandlerMapping Handler configuration of the object (including objects and Handler object Handler corresponding interceptor), and finally returns to the form of the object HandlerExecutionChain
The obtained ⑶ DispatcherServlet Handler selects an appropriate HandlerAdapter. (Note: If successful HandlerAdapter, this time will begin preHandler blocker (...) method)
⑷ Request extraction of model data is filled into the reference Handler, started Handler (Controller). Participate in the process of filling Handler, depending on your configuration, Spring will help you to do some extra work:
HttpMessageConveter: a request message (e.g. Json, xml data, etc.) into a subject, convert the object to the specified response information
Data conversion: conversion of the data request message. The String is converted into Integer, Double, etc.
Radicals of data: data format of the request message. As will be converted into a string of numbers formatted or formatted date
Data Validation: validation of the data (the length, format, etc.), verification result storage or Error to BindingResult
After ⑸Handler executed, returns a ModelAndView object to DispatcherServlet
The return ⑹ ModelAndView selecting a suitable ViewResolver (Spring must be registered to the container ViewResolver) returned to DispatcherServlet
⑺ViewResolver combination of Model and View, to render the view