IOC= Inversion of control dependency Injection
Injection Type:
- Interface injection;
- Set Value injection;
- Construct sub-injection;
Key categories:
Beanwrapper, beanfactory, applicationcontext
1. beanwrapper: provides a general property setting mechanism;
Instance:
Object OBJ = Class. forname ( " Net. User " );
Beanwrapper BW = New Beanwrapper (OBJ );
Bw. setpropertyvalue ( " Name " , " Erica " );
2. beanfactory: creates and maintains bean instances;
Instance:
Inputstream is = New Fileinputstream ( " Bean. xml " );
Xmlbeanfactory Factory = New Xmlfactory (is );
// "Bean. xml" has "theaction"'s config
Action action = (Action) Factory. getbean ( " Theaction " );
3. applictioncontext: provides more features integrated with the application architecture, including: International support, resource access, event propagation, and multi-instance loading.
For Web applications, spring can configure the web. XML loading. When loading, read the * \ applicationcontext. xml configuration file for initialization.
You can use the webapplicationcontextutils. getwebapplicationcontext () method to obtain the applicationcontext instance of the current context.
Request Processing Process:
1. encapsulate the input elements on the web page as a (request) data object;
2. Scheduling logic concerns based on different requests and passing in (request) Data Objects as parameters;
3. After the logical processing unit is completed, a result data object is returned;
4. Combine the data in the result data object with the pre-designed presentation layer to present the data to the user.
Key class: dispatcherservlet
Core Engine of dispatcherservlet for Request Scheduling
Default load/WEB-INF/<servlet Name>-servlet. xml file, which contains the allocation policy of logical units, structure:
- Viewresolver => internalresourceviewresolver
Define the viewer type and related attributes (v) <--> (m)
- * Mapping => simpleurlhandlermapping
Define the association between requests and logical units. (Link ..)
- * Controler => Custom logical unit
Define attributes of custom logical units (c) <--> (m)
Spring MVC configuration mode:
Spring's deispatcherservlet will initialize several internal modules supported by spring MVC when loaded. Such as viewer, exception handling, and handlermapping. You can initialize and define these modules in the configuration file that is automatically called by this class.