SSM Framework Integration

SSM Framework Integration

  • Spring MVC is responsible for implementing MVC design patterns

  • MyBatis is responsible for the data persistence layer

  • Spring is responsible for managing the creation and dependency injection of related objects used by Spring MVC and MyBatis

    SSM Framework Integration, actually Spring and MyBatis Integration, because Spring MVC is a sub-module of Spring

1 Project Environment

  • IDEA 2021.2.3 Ultimate Edition
  • MySQL 8.0.26
  • Tomcat 10.0.11
  • Maven 3.8.3

2 Foundation environment building

  • Create a maven project
  • Introducing project-dependent jar packages
  • Introducing the bootstrap front-end framework

3 Profile*

  • Step 1: pom.xml introduces dependent jar packages

          <dependencies>
            <!-- SpringMVC -->
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-webmvc</artifactId>
                <version>5.2.18.RELEASE</version>
            </dependency>
    
            <!-- Spring JDBC Transaction Control -->
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-jdbc</artifactId>
                <version>5.2.18.RELEASE</version>
            </dependency>
    
            <!-- Spring AOP AoP -->
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-aop</artifactId>
                <version>5.2.18.RELEASE</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-aspects</artifactId>
                <version>5.2.18.RELEASE</version>
            </dependency>
    
            <!-- Spring TestContext For Note Import Spring Global Profile-->
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-test</artifactId>
                <version>5.2.18.RELEASE</version>
            </dependency>
    
            <!-- MyBatis -->
            <dependency>
                <groupId>org.mybatis</groupId>
                <artifactId>mybatis</artifactId>
                <version>3.5.7</version>
            </dependency>
    
            <!-- MBG MyBatis reverse engineering -->
            <dependency>
                <groupId>org.mybatis.generator</groupId>
                <artifactId>mybatis-generator-core</artifactId>
                <version>1.3.7</version>
            </dependency>
    
            <!-- MyBatis integration Spring Adaptation packages for -->
            <dependency>
                <groupId>org.mybatis</groupId>
                <artifactId>mybatis-spring</artifactId>
                <version>1.3.1</version>
            </dependency>
    
            <!-- MySQL drive -->
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <version>8.0.26</version>
            </dependency>
    
            <!-- Database Connection Pool Druid -->
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>druid</artifactId>
                <version>1.2.6</version>
            </dependency>
    
            <!-- JSTL: JSP Label Library-->
            <dependency>
                <groupId>jstl</groupId>
                <artifactId>jstl</artifactId>
                <version>1.2</version>
            </dependency>
    
            <!-- ServletAPI -->
            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>javax.servlet-api</artifactId>
                <version>3.1.0</version>
            </dependency>
    
            <!-- lombok -->
            <dependency>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <version>1.18.20</version>
                <scope>provided</scope>
            </dependency>
    
            <!-- Journal -->
            <!-- Be careful log4j and slf4j Version Compatibility Issues for -->
            <dependency>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
                <version>1.2.17</version>
            </dependency>
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-log4j12</artifactId>
                <version>1.7.30</version>
            </dependency>
    
            <!-- Junit -->
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>4.13.1</version>
                <scope>compile</scope>
            </dependency>
    
            <!-- Spring5 and Thymeleaf Integration Package -->
            <dependency>
                <groupId>org.thymeleaf</groupId>
                <artifactId>thymeleaf-spring5</artifactId>
                <version>3.0.12.RELEASE</version>
            </dependency>
    
            <!-- Jackson Handle Json data -->
            <dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-databind</artifactId>
                <version>2.13.0</version>
            </dependency>
    
        </dependencies>
    
  • Step 2: web.xml configuration interceptor intercepts browser requests under WEB-INF folder

    • Configure the SpringMVC front-end controller Dispatcher Servlet, unify requests sent by browsers, and specify the address of the springMVC configuration file
    • Character Encoding Filter
    • Configure HiddenHttpMethodFilter to filter requests
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
             version="4.0">
    
      <!-- To configure SpringMVC Front End Controller DispatcherServlet,Unified processing of browser-sent requests -->
      <servlet>
        <servlet-name>DispatcherServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <!-- Specify by initialization parameters SpringMVC Location and name of profile -->
        <init-param>
          <!-- contextConfigLocation Is Fixed Value -->
          <param-name>contextConfigLocation</param-name>
          <!-- Use classpath:Represents finding a configuration file from a class path, for example maven In the project src/main/resources -->
          <param-value>classpath:springMVC.xml</param-value>
        </init-param>
    
        <!--
            As a core component of the framework, there is a lot of initialization to do during startup
            These operations, performed on the first request, can seriously affect access speed
            So this tag will start the control DispatcherServlet Initialization time is advanced to server startup
        -->
        <load-on-startup>1</load-on-startup>
      </servlet>
    
      <servlet-mapping>
        <servlet-name>DispatcherServlet</servlet-name>
        <!--
            Set up springMVC Request path for requests that the core controller can handle
            / The matched request can be/login or.html or.js or.css Request path of mode
            however / Unmatched.jsp Request Path
        -->
        <url-pattern>/</url-pattern>  <!-- Notice that there is only one /  -->
      </servlet-mapping>
    
      <!--To configure springMVC A character encoding filter for preventing scrambling; Character encoding filters, always in front of all filters-->
      <filter>
        <filter-name>CharacterEncodingFilter</filter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
        <init-param>
          <param-name>encoding</param-name>
          <param-value>UTF-8</param-value>
        </init-param>
        <!--  Note that the settings here must have two parameters true,Viewable Source  -->
        <init-param>
          <param-name>forceResponseEncoding</param-name>
          <param-value>true</param-value>
        </init-param>
        <init-param>
          <param-name>forceRequestEncoding</param-name>
          <param-value>true</param-value>
        </init-param>
      </filter>
      <filter-mapping>
        <filter-name>CharacterEncodingFilter</filter-name>
        <url-pattern>/*</url-pattern> <!-- /* Is to include all requests,/ Is not included.jsp Request for -->
      </filter-mapping>
    
      <!-- Use Rest Stylistic URI,Make the page normal post Request conversion to specified delete perhaps put request -->
      <!--To configure HiddenHttpMethodFilter,Filter the request mode, and POST Request Conversion to PUT,DELETE request-->
      <filter>
        <filter-name>HiddenHttpMethodFilter</filter-name>
        <filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
      </filter>
      <filter-mapping>
        <filter-name>HiddenHttpMethodFilter</filter-name>
        <url-pattern>/*</url-pattern> <!-- Filter all requests -->
      </filter-mapping>
    
      <!-- Another way to load static resources -->
    <!--  <servlet-mapping>-->
    <!--    <servlet-name>default</servlet-name>-->
    <!--    <url-pattern>*.js</url-pattern>-->
    <!--  </servlet-mapping>-->
    <!--  <servlet-mapping>-->
    <!--    <servlet-name>default</servlet-name>-->
    <!--    <url-pattern>*.css</url-pattern>-->
    <!--  </servlet-mapping>-->
    <!--  <servlet-mapping>-->
    <!--    <servlet-name>default</servlet-name>-->
    <!--    <url-pattern>*.jpg</url-pattern>-->
    <!--  </servlet-mapping>-->
    </web-app>
    
  • Step 3: Configure SpringMVC with springMVC.xml under the resources resource directory

    • Open the scan component to scan annotation configured classes
    • Configure thymeleaf view resolver
    • Open access to static resources
    • Turn on mvc annotation driver
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:context="http://www.springframework.org/schema/context"
           xmlns:mvc="http://www.springframework.org/schema/mvc"
           xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd">
    
        <!--  SpringMVC Configuration file containing control and configuration of site jump logic  -->
        <!--Open Scan Component-->
        <context:component-scan base-package="com.atguigu.ssmcrud"></context:component-scan>
    
        <!--To configure thymeleaf View parser for easy page return-->
        <bean id="viewResolver" class="org.thymeleaf.spring5.view.ThymeleafViewResolver">
            <property name="order" value="1"/> <!--Priority Setting-->
            <property name="characterEncoding" value="UTF-8"/>
            <property name="templateEngine"> <!--Template-->
                <bean class="org.thymeleaf.spring5.SpringTemplateEngine">
                    <property name="templateResolver">
                        <bean class="org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver">
                            <!-- View Prefix -->
                            <property name="prefix" value="/WEB-INF/views/"/>
                            <!-- View Suffix -->
                            <property name="suffix" value=".jsp"/>
                            <property name="templateMode" value="HTML5"/>
                            <property name="characterEncoding" value="UTF-8" />
                        </bean>
                    </property>
                </bean>
            </property>
        </bean>
    
        <!--Configure the view controller to map requests to jump pages-->
    <!--    <mvc:view-controller path="/" view-name="index"></mvc:view-controller>-->
    
        <!--Opening access to static resources will springMVC Unhandled request handed over to tomcat-->
        <mvc:default-servlet-handler/>
    
        <!--open mvc Annotation driven to avoid other annotation failures-->
        <mvc:annotation-driven />
    
    </beans>
    
  • Step 4: Under the resources folder, configure the database connection and log files, dbconfig.properties, and log4j.properties

    dbconfig.properties

    mysql.driver=com.mysql.cj.jdbc.Driver
    mysql.url=jdbc:mysql://localhost:3306/mybatisdb?allowMultiQueries=true
    mysql.username=root
    mysql.password=wenhao
    

    log4j.properties

    log4j.rootLogger=DEBUG,A1
    
    log4j.appender.A1=org.apache.log4j.ConsoleAppender
    log4j.appender.A1.layout=org.apache.log4j.PatternLayout
    log4j.appender.A1.layout.ConversionPattern=[%t] [%c]-[%p] %m%n
    
  • Step 5: Under the resources folder, the springApplicationConfig.xml global configuration file configures Spring, related to the main configuration and business logic

    • Turn on the scan component, there is no need to scan controller

    • Integrate MyBatis

      1. Introduce the database configuration file properties file location, under the classpath - >resources directory
    1. Configure the data source (database connection pool), using c3p0 or Druid
    2. Configure the integration of Spring and MyBatis: SqlSessionFactory, which specifies the MyBatis global profile location
    3. Configure sqlSession
    4. Configure scanners to scan custom mapper interfaces
    5. Configure a sqlSession that can be batched
    • Configuration of Transaction Control (Transaction Manager)

      1. Establish mapping to database connection pool
      2. Open annotation-based transactions
      3. Configuration Transaction Enhancement
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:context="http://www.springframework.org/schema/context"
           xmlns:aop="http://www.springframework.org/schema/aop"
           xmlns:tx="http://www.springframework.org/schema/tx"
           xmlns="http://www.springframework.org/schema/beans"
           xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans.xsd
           http://www.springframework.org/schema/context
           https://www.springframework.org/schema/context/spring-context.xsd
           http://www.springframework.org/schema/aop
           https://www.springframework.org/schema/aop/spring-aop.xsd
           http://www.springframework.org/schema/tx
           http://www.springframework.org/schema/tx/spring-tx.xsd">
    
        <!--  spring Configuration file, where the main configuration is business logic related  -->
    
        <!--  spring No scanning required controller,because spring Component scan only, control layer processing is handled to springMVC Handle  -->
        <context:component-scan base-package="com.atguigu.ssmcrud">
            <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
        </context:component-scan>
    
        <!--  =======================integration MyBatis=======================  -->
        <!--  Introducing a database configuration file  -->
        <context:property-placeholder location="classpath:dbconfig.properties"/>
    
        <!-- Configure the data source, which is used here druid Database Connection Pool-->
        <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
            <property name="username" value="${mysql.username}"></property>
            <property name="password" value="${mysql.password}"></property>
            <property name="url" value="${mysql.url}"></property>
            <property name="driverClassName" value="${mysql.driver}"></property>
            <property name="initialSize" value="5"></property>
            <property name="maxActive" value="10"></property>
        </bean>
    
        <!-- Configuration and MyBatis Integration: SqlSessionFactory -->
        <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
            <!--Appoint MyBatis Location of global profile-->
            <property name="configLocation" value="classpath:mybatisConfig.xml"></property>
            <!--Establish mapping relationship with database connection pool-->
            <property name="dataSource" ref="dataSource"></property>
            <!--Appoint mybatis,mapper Location of the file-->
            <property name="mapperLocations" value="classpath:mapper/*.xml"></property>
        </bean>
    
        <!-- Configure the scanner to MyBatis Of Dao Interface implementation and joining ioc In a container, i.e. scan for custom Mapper Interface -->
        <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
            <!--Scan all dao Implementation of the interface, joined by ioc In container-->
            <property name="basePackage" value="com.atguigu.ssmcrud.dao"></property>
        </bean>
    
        <!--Configure a batch executable sqlSession-->
        <bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate">
            <constructor-arg name="sqlSessionFactory" ref="sqlSessionFactory"/>
            <constructor-arg name="executorType" value="BATCH"/>
        </bean>
    
        <!-- ==================Configuration of Transaction Control (Transaction Manager)====================== -->
        <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
            <!--Control database connection pool-->
            <property name="dataSource" ref="dataSource"></property>
        </bean>
    
        <!--Open annotation-based transactions using xml Configured transaction-->
        <aop:config>
            <!--Cut-in expression, service All the classes and methods below can be used as starting points. Which methods might get cut into the transaction-->
            <aop:pointcut id="txPoint" expression="execution(* com.atguigu.ssmcrud.service..*(..))"/>
            <!--Configure transaction enhancements, rules to be entered by txAdvice Specify, how to cut in by txPoint Appoint-->
            <aop:advisor advice-ref="txAdvice" pointcut-ref="txPoint"/>
        </aop:config>
    
        <!--Configure transaction enhancements, what to do when a transaction enters, and how to handle it (how a transaction enters)-->
        <tx:advice id="txAdvice" transaction-manager="transactionManager">
            <tx:attributes>
                <!--All methods that this entry point enters are transactional methods-->
                <tx:method name="*"/>
                <!--with get All starting methods are considered query methods-->
                <tx:method name="get*" read-only="true"/>
            </tx:attributes>
        </tx:advice>
    
    </beans>
    
  • Step 6: Under the resources file, configure the MyBatis configuration file with mybatisConfig.xml

    • Configure some property settings for MyBatis (e.g. settings, typeAliases, etc., the properties property is already configured externally, in the springApplicationConfig.xml file)
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE configuration
            PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
            "http://mybatis.org/dtd/mybatis-3-config.dtd">
    <!--MyBatis Configuration file, configure some MyBatis Poorly configured settings-->
    <configuration>
        <settings>
            <!--Turn on hump naming mapping-->
            <setting name="mapUnderscoreToCamelCase" value="true"/>
            <!--Can return to auto-generated primary key-->
            <setting name="useGeneratedKeys" value="true"/>
        </settings>
    </configuration>
    
  • Step 7: Under the resources file, the mbg.xml configuration reverse-generates properties

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE generatorConfiguration
            PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
            "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
    <generatorConfiguration>
        <properties resource="dbconfig.properties"/>
        <!--
            targetRuntime="MyBatis3Simple":Generate a simple version of CRUD
            MyBatis3:Deluxe version for complex databases CRUD operation
         -->
        <context id="DB2Tables" targetRuntime="MyBatis3">
    
            <!-- Clear comments in the build file, which must be defined before the build file is generated -->
            <commentGenerator>
                <property name="suppressAllComments" value="true"/>
            </commentGenerator>
    
            <!-- jdbcConnection: Specify how to connect to the target database -->
            <jdbcConnection driverClass="${mysql.driver}"
                            connectionURL="${mysql.url}"
                            userId="${mysql.username}"
                            password="${mysql.password}">
            </jdbcConnection>
    
            <!--Type Parser-->
            <javaTypeResolver >
                <property name="forceBigDecimals" value="false" />
            </javaTypeResolver>
    
            <!-- javaModelGenerator: Appoint javaBean Generation strategy (location of generation)
                targetPackage="test.model": Target Package Name
                targetProject="\MBGTestProject\src": Target Engineering
            -->
            <javaModelGenerator targetPackage="com.atguigu.ssmcrud.bean"
                                targetProject=".\src\main\java">
                <property name="enableSubPackages" value="true" />
                <property name="trimStrings" value="true" />
            </javaModelGenerator>
    
            <!-- sqlMapGenerator: sql Statement to Interface Method Mapping Generation Policy xml configuration file -->
            <!-- Appoint sql Mapping File Generation Location: Generated to resources Under file mapper In folder-->
            <sqlMapGenerator targetPackage="mapper"
                             targetProject=".\src\main\resources">
                <property name="enableSubPackages" value="true" />
            </sqlMapGenerator>
    
            <!-- javaClientGenerator: Appoint mapper Location of interface methods -->
            <!-- Appoint dao Location of interface generation: mapper Interface (Business Behavior Interface) -->
            <javaClientGenerator type="XMLMAPPER" targetPackage="com.atguigu.ssmcrud.dao"
                                 targetProject=".\src\main\java">
                <property name="enableSubPackages" value="true" />
            </javaClientGenerator>
    
            <!-- table Label: Specify the generation policy for each table -->
            <!-- Specify which tables in the database you want to reverse analyze: create from the tables javaBean -->
            <table tableName="tbl_emp" domainObjectName="Employee"></table>
            <table tableName="tbl_dept" domainObjectName="Department"></table>
    
        </context>
    </generatorConfiguration>
    

4 Tests

4.1 Database Creation

Create a name ssm_crud's database

  • This database has tbl_dept, tbl_emp two tables
CREATE TABLE `tbl_emp` (
  `emp_id` int(11) NOT NULL AUTO_INCREMENT,
  `emp_name` varchar(255) DEFAULT NULL,
  `gender` char(1) DEFAULT NULL,
  `email` varchar(255) DEFAULT NULL,
  `d_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`emp_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


CREATE TABLE `tbl_dept` (
  `dept_id` int(11) NOT NULL AUTO_INCREMENT,
  `dept_name` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`dept_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  • You need to add a foreign key, tbl_ D_of EMP The ID field is tbl_ Foreign key to dept, from table tbl_ Referenced field dept_of Dept ID is its primary key

4.2 Use Spring unit tests to operate on databases

Import Spring's configuration files using annotations and use Spring unit tests (add dependencies)

        <!-- Spring TestContext For Note Import Spring Global Profile-->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>5.2.18.RELEASE</version>
        </dependency>

Test code:

/*
*   It is recommended that Spring projects use Spring's unit tests to automatically inject the components we need
*       1. Import SpringTest dependencies, note the scope tag, remove test
*       2. @ContextConfiguration Specify the location of the Spring profile
*       3. autowired Components to use
* */

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:springApplicationConfig.xml"})
public class MapperTest {

    /*
    * ==========Using annotations ============
    *   Since the Spring configuration file was loaded first, use annotations, auto-injection, and get instances
    * */
    @Autowired
    DepartmentMapper departmentMapper;

    @Autowired
    EmployeeMapper employeeMapper;

    @Autowired
    SqlSession sqlSession;

    /*
    *   Test DepartmentMapper
    * */
    @Test
    public void testCRUD(){
//        // ==============Traditional method============Traditional method========
//        // 1. Create Spring IOC container
//        ApplicationContext ioc = new ClassPathXmlApplicationContext("classpath:springApplicationConfig.xml");
//        // 2. Get an instance of the mapper interface from the container because the mapper interface is scanned and added in the spring configuration file
//        DepartmentMapper departmentMapper = ioc.getBean(DepartmentMapper.class);

        // 1. Adding Department information, using insert information parameter is optional, so select insertSelective, which is the insertSelective parameter insertion method because id is self-increasing
        departmentMapper.insertSelective(new Department(null, "Development Department"));
        departmentMapper.insertSelective(new Department(null, "Test Department"));

        // 2. Generate employee data and test employee insertion
        employeeMapper.insertSelective(new Employee(null, "Jerry", "M", "jerry@123.com", 1));

        // 3. Bulk insertion of multiple employees: Bulk operations require setting up a sqlSession in the Spring global configuration file that can perform bulk operations

//        for(){//If the auto-injected mapper object is used directly, the corresponding number of sqlSession s are established regardless of the number of loops, not the batch operation
//            employeeMapper.insertSelective(new Employee());
//        }
        // Use batch processing sqlSession already configured in the spring configuration file
        EmployeeMapper mapper = sqlSession.getMapper(EmployeeMapper.class);
        for (int i = 0; i < 200; i++) {
            String uid = UUID.randomUUID().toString().substring(0, 5) + i;
            mapper.insertSelective(new Employee(null, uid, "W", uid + "@123.com", 1));
        }
        for (int i = 0; i < 200; i++) {
            String uid = UUID.randomUUID().toString().substring(0, 5) + i;
            mapper.insertSelective(new Employee(null, uid, "M", uid + "@qq.com", 2));
        }
        for (int i = 0; i < 200; i++) {
            String uid = UUID.randomUUID().toString().substring(0, 5) + i;
            mapper.insertSelective(new Employee(null, uid, "M", uid + "@gmail.com", 1));
        }

    }
}

2.5 Improve project structure

  • bean: entity, entity level, implements the mapping of database tables, often a data object.
  • controller: the control layer to handle requests from the browser accordingly.
  • dao: data access object layer, create interface, define the operation method of CRUD on database, and establish mapping with mapper xml configuration file.
  • service: business logic layer, to achieve the true logic of the business, to write business logic code, to achieve tangent operations, and so on

Tags: Mybatis Spring Spring MVC SSM

Posted on Tue, 30 Nov 2021 14:39:51 -0500 by notsleepy