Spring Framework Study Notes (4)

Connected to Spring Framework Study Notes (3)

Declarative transaction management (xml configuration)

1 Configuration file method using aop idea configuration

The first step is to configure the transaction manager

The second step configures transaction enhancements

 

The third step configures the slice

 

 

Declarative Transaction Management (Annotations)

The first step is to configure the transaction manager

 

The second step configures transaction annotations

 

The third step is to add an annotation to the class where the method to use the transaction is located

 

SSH three framework integration:

(1)struts2

(2)hibernate5.x

(3)spring4.x

Review the SSH framework knowledge points:

Hibernate framework

1 hibernate core configuration file

(0) orm idea

  - Object Relational Mapping

(1) Database information

(2) hibernate information

(3) Mapping configuration

(4) hibernate core configuration file

  - If you simply use the hibernate framework, the core configuration file name hibernate.cfg.xml and the location src are fixed below

  - When integrating hibernate and spring, there is no fixed requirement for the name and location of the hibernate core configuration file

2 hibernate mapping configuration file

(1) Mapping relationship between entity class and database table - using orm idea

3 steps of hibernate operation

(1) Encapsulate the hibernate framework in the spring framework and use hibernateTemplate

Struts2 framework

1 Action operation

(1) Actions are created in three ways

  - Inherit class ActionSupport

(2) Configure the action access path

  - Create a struts.xml configuration file, the file name and location are fixed under src

(3) Configure multiple methods for accessing actions

  - Use wildcard configuration

(4) Get form submission data in action

  - Get the request object

  ** Obtained using the ServletActionContext class

  - Property encapsulation

  - Model driven (emphasis)

  - Expression encapsulation

(5) Operating domain objects in action

  - Use ServletActionContext to get domain object

(6) Configure the filter of struts2

2-value stack

(1) Put data into the value stack

  - set method

  - push method

  - Define variables and generate get methods

(2) Get data from the value stack

  - Use struts2 tag + ognl to get in jsp

  - <s:property>

  - <s:iterator>

3 Interceptors

(1) AOP and Chain of Responsibility Model

(2) Custom interceptor

  - Inherit MethodFilterInterceptor

  - Override methods in the class

  - Configure interceptor and action association

 

Spring Framework

1 spring core configuration file

(1) There are no fixed requirements for name and location

(2) Introduce schema constraints in the spring core configuration file 

2 Create objects

(1) xml configuration method: <bean id=”” class=”” scope=””/>

(2) Annotation method: four annotations

3 inject properties (object type properties)

(1) xml configuration method:

(2) Annotation method: two annotations

    - autowired

    - resource

3 Implemented using ServletContext objects and listeners

(1) When the server starts, load the spring configuration file and create the object

(2) Configure spring listeners

(3) Specify the location of the spring configuration file

4 jdbcTemplate

5 spring transaction configuration

(1) xml method

(2) Annotation method

 

SSH framework integration ideas

1 The three major frameworks are applied in the three-tier structure of javaee

2 struts2 framework and spring integration

(1) The action of struts2 is configured in spring

3 Spring framework and hibernate framework integration

(1) Hibernate's sessionFactory is handed over to spring configuration

(2) Give the hibernate database configuration to the spring configuration

Integrate struts2 and spring framework

1 Hand over the action of struts2 to spring management

2 Implementation process

The first step is to import the jar package of struts2

(1) Import the jar package for integration

The second step is to create an action

The third step is to create the struts2 core configuration file and configure the action

(1) The location is under src, and the name is struts.xml

The fourth step configures the struts2 filter

The fifth step is to import the spring jar package

The sixth step is to create a spring configuration file

(1) Introduce constraints

(2) Configure the spring listener

 

(3) Specify the location of the spring configuration file

 

 

The seventh step is to hand over the action to spring for configuration (***)

(1) Configure the action object in spring, and also configure the action object in struts.xml

(2) Solve:

You only need to configure the action object in spring, not in struts.xml

Spring framework integrates hibernate framework 

 

 

 

 

To be continued......................

Guess you like

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