java-ssm整合

整合

1. 项目步骤

1.1 创建maven项目

spring章节笔记中有截图

1.2 pom.xml引入jar依赖

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<spring.version>5.2.13.RELEASE</spring.version>
<mybatis.version>3.5.6</mybatis.version>
<mybatis.spring.version>1.3.3</mybatis.spring.version>
<pagehelper.version>5.1.10</pagehelper.version>
<mysql.version>8.0.23</mysql.version>
<druid.version>1.2.3</druid.version>
<servlet-api.version>4.0.1</servlet-api.version>
<jackson.version>2.9.6</jackson.version>
<log4j.version>1.2.17</log4j.version>
<junit.version>4.12</junit.version>
</properties>

<!--1-->
<packaging>war</packaging>
<!--SSM整合 spring-springMVC mybatis mysql -->
<!-- 集中定义依赖版本号:一定要注意版本号,避免踩坑-->
<dependencies>
<!-- spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<version>${spring.version}</version>
</dependency>
<!--文件上传-->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.1</version>
</dependency>
<!-- Mybatis -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>${mybatis.version}</version>
</dependency>
<!-- Mybatis spring整合需要的jar -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>${mybatis.spring.version}</version>
</dependency>
<!-- 分页插件 -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>${pagehelper.version}</version>
</dependency>
<!-- MySql -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency>
<!-- 连接池 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>${druid.version}</version>
</dependency>
<!-- servlet -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${servlet-api.version}</version>
<scope>provided</scope>
</dependency>
<!-- Jackson Json处理工具包 -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<!-- log4j -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
<!-- junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
</dependency>
<!--@Resource注解的依赖-->
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>
</dependencies>

<!-- 插件配置 -->
<build>
<resources>
<resource>
<directory>src/main/java</directory><!--所在的目录-->
<includes><!--包括目录下的.properties,.xml 文件都会被扫描到-->
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
<plugins>
<!-- 设置项目的编译版本 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<!-- 设置tomcat插件 -->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<!-- 指定端口 -->
<port>80</port>
<!-- 请求路径 -->
<path>/</path>
<uriEncoding>UTF-8</uriEncoding>
</configuration>
</plugin>
<!--反向生成插件-->
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.5</version>
<configuration>
<!--配置文件的路径-->
<configurationFile>src/main/resources/generatorConfig.xml</configurationFile>
<overwrite>true</overwrite>
</configuration>
<dependencies>
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.3.5</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

1.3 编写Mybatis的配置文件

Mybatis的配置文件mybatis.xml

仅负责日志部分

1
2
3
4
5
6
7
8
9
10
<?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">
<configuration>
<settings>
<setting name="logImpl" value="LOG4J" />
</settings>
<!--spring 接管其他的工作 数据源 映射文件注册 插件-->
</configuration>

日志配置文件文件log4j.properties:

1
2
3
4
5
6
# Global logging configuration  info  warning  error
log4j.rootLogger=DEBUG,stdout
# Console output...
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n

剩余部分的功能都交给spring配置文件进行接管

1.4 编写Spring的配置文件spring.xml

连接数据库的参数配置文件jdbc.properties

注意案例中使用的数据库版本是MySQL8

jdbc.properties:

1
2
3
4
jdbc.driver=com.mysql.cj.jdbc.Driver 
jdbc.url=jdbc:mysql://127.0.0.1:3306/myssm_kkb?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT
jdbc.username=root
jdbc.password=QW06125231

spring.xml功能:

  1. 原有的创建对象的功能

spring接管mybatis的功能:

  1. 配置数据源jdbc的信息,又mybatis文件也要导入
  2. 配置别名
  3. 扫描映射文件
  4. 添加插件
  5. 接口的动态映射
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?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:tx="http://www.springframework.org/schema/tx"
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/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
<!--这些包中添加注解之后对象的创建权限就交给spring容器-->
<context:component-scan base-package="com.kkb.mapper,com.kkb.service"/>

<!--spring整合mybatis -->
<context:property-placeholder location="classpath*:jdbc.properties"/>
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
<!--可以根据url自动检查出驱动-->
<!--<property name="driverClassName" value="${jdbc.driver}"></property>-->
<property name="url" value="${jdbc.url}"></property>
<property name="username" value="${jdbc.username}"></property>
<property name="password" value="${jdbc.password}"></property>
</bean>

<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<!--如果有mybatis的单独的配置文件,需要在此引入 -->
<property name="configLocation" value="classpath:mybatis.xml"/>
<property name="dataSource" ref="dataSource"/>
<!--配置别名-->
<property name="typeAliasesPackage" value="com.kkb.pojo"/>
<!--映射文件-->
<!--<property name="mapperLocations" value="com/kkb/mappper/*.xml"/>-->
<!--插件-->
<property name="plugins">
<array>
<!--分页-->
<bean class="com.github.pagehelper.PageInterceptor">
<property name="properties">
<value>
reasonable=true
</value>
</property>
</bean>
</array>
</property>
</bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.kkb.mapper"/>
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
</bean>

<!-- 通过注解方式实现事务 -->
<tx:annotation-driven transaction-manager="transactionManager"/>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
</beans>

1.5 编写SpringMVC的配置文件springmvc.xml

  1. springMVC负责逻辑业务层,controller的创建交由springmvc来完成
  2. 视图解析器
  3. 静态资源映射
  4. 文件上传
  5. 导入静态前端资源
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?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 http://www.springframework.org/schema/mvc/spring-mvc.xsd
">
<!--springmvc的配置文件:控制器的bean对象都在这里扫描-->
<context:component-scan base-package="com.kkb.controller"/>
<mvc:annotation-driven/>
<!--视图解析器-->
<bean id="internalResourceViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/pages/"/>
<property name="suffix" value=".html"/>
</bean>
<!--静态资源处理-->
<mvc:resources mapping="/img/**" location="/img/"/>
<mvc:resources mapping="/js/**" location="/js/"/>
<mvc:resources mapping="/css/**" location="/css/"/>
<mvc:resources mapping="/fonts/**" location="/fonts/"/>
<mvc:resources mapping="/static/**" location="/static/"/>
<mvc:resources mapping="/pages/**" location="/pages/"/>
<!--文件上传-->
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
</bean>
</beans>

1.6 编写web.xml配置文件

  1. 配置spring.xml和springmvc.xml
  2. 配置拦截路径url,所有请求都会被前端控制器拦截处理
  3. rest和防乱码的过滤器
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?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">
<welcome-file-list>
<welcome-file>/pages/index.html</welcome-file>
</welcome-file-list>

<!--spring的配置-->
<context-param>
<!--contextConfigLocation:表示用于加载 Bean的配置文件
classpath和classpath*区别:
classpath:只会到你的class路径中查找找文件。
classpath*:不仅包含class路径,还包括jar文件中(class路径)进行查找。
-->
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:spring.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!--SpringMVC的配置-->
<servlet>
<servlet-name>dispatcherServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!-- 创建前端控制器的时候读取springmvc配置文件启动ioc容器 -->
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:springmvc.xml</param-value>
</init-param>
<!-- Tomcat启动就创建此对象 -->
<load-on-startup>1</load-on-startup>
</servlet>
<!-- 配置拦截路径url,所有请求都会被前端控制器拦截处理 -->
<servlet-mapping>
<servlet-name>dispatcherServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>

<!-- 使用Rest风格的URI 将页面普通的post请求转为指定的delete或者put请求
原理:在Ajax中发送post请求后,带_method参数,将其修改为PUT,或者DELETE请求-->
<filter>
<filter-name>httpMethodFilter</filter-name>
<filter-class>
org.springframework.web.filter.HiddenHttpMethodFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>httpMethodFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<!--注册字符集过滤器:post请求中文乱码问题的解决方案-->
<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>
<!--强制request使用字符集encoding-->
<init-param>
<param-name>forceRequestEncoding</param-name>
<param-value>true</param-value>
</init-param>
<!--强制response使用字符集encoding-->
<init-param>
<param-name>forceResponseEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>characterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>

1.7 测试

启动项目,浏览器访问http://localhost:8088/。看到如图所示页面表示项目整合成功。

1.8 No mappering for GET

在实际运行时网页报404错误,过滤器打印信息:NO mappering for GET

说明静态页面资源的没有扫描到

解决方法:

target中都看不到静态页面,说明没有扫描到静态资源,在pom.xml的资源扫描插件中添加多resource包下的.html资源的扫描

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<resources>
<resource>
<directory>src/main/java</directory>
<!--所在的目录-->
<includes>
<!--包括目录下的.properties,.xml 文件都会被扫描到-->
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.*</include>
</includes>
</resource>
</resources>

2. 使用mybatis反向生成实体类、dao和映射文件

2.1 反向生成配置文件generatorConfig.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?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>
<!--1、数据库驱动jar:添加自己的jar路径 -->
<classPathEntry
location="D:\repository\mysql\mysql-connector-java\8.0.23\mysql-connector-java-8.0.23.jar" />

<context id="MyBatis" targetRuntime="MyBatis3">

<!--去除注释 -->
<commentGenerator>
<property name="suppressAllComments" value="true" />
</commentGenerator>

<!--2、数据库连接 -->
<jdbcConnection driverClass="com.mysql.cj.jdbc.Driver"
connectionURL="jdbc:mysql://127.0.0.1:3306/myssm_kkb?useUnicode=true&amp;characterEncoding=utf-8&amp;useSSL=false&amp;serverTimezone=GMT"
userId="root"
password="QW06125231">
</jdbcConnection>

<!-- 默认false,把JDBC DECIMAL 和 NUMERIC 类型解析为 Integer;
为 true时把JDBC DECIMAL和NUMERIC类型解析为java.math.BigDecimal -->
<javaTypeResolver>
<property name="forceBigDecimals" value="false" />
</javaTypeResolver>

<!--3、生成实体类 指定包名 以及生成的地址 (可以自定义地址,但是路径不存在不会自动创建
使用Maven生成在target目录下,会自动创建) -->
<javaModelGenerator targetPackage="com.kkb.pojo"
targetProject="src\main\java">
<property name="trimStrings" value="true" />
</javaModelGenerator>

<!--4、生成SQLmapper.xml文件 -->
<sqlMapGenerator targetPackage="com.kkb.mapper"
targetProject="src\main\resources">
</sqlMapGenerator>
<!--5、生成Dao(Mapper)文件,生成接口 -->
<javaClientGenerator type="XMLMAPPER"
targetPackage="com.kkb.mapper"
targetProject="src\main\java">
</javaClientGenerator>
<!--6、要生成哪些表(更改tableName和domainObjectName就可以) -->
<!-- tableName:要生成的表名
enableCountByExample:Count语句中加入where条件查询,默认为true开启
enableUpdateByExample:Update语句中加入where条件查询,默认为true开启
enableDeleteByExample:Delete语句中加入where条件查询,默认为true开启
enableSelectByExample:Select多条语句中加入where条件查询,默认为true开启
selectByExampleQueryId:Select单个对象语句中加入where条件查询,默认为true开启
-->
<table tableName="Team">
<property name="useActualColumnNames" value="true"/>
</table>
<table tableName="Player">
<property name="useActualColumnNames" value="true"/>
</table>
<table tableName="game">
<property name="useActualColumnNames" value="true"/>
</table>
<table tableName="GameType">
<property name="useActualColumnNames" value="true"/>
</table>
<table tableName="Admins">
<property name="useActualColumnNames" value="true"/>
</table>
<table tableName="AdminRole">
<property name="useActualColumnNames" value="true"/>
</table>
</context>
</generatorConfiguration>

2.2 运行插件

注意只能运行一次,运行完毕显示BUILD SUCCESS即为成功。

image-20211227163253716

2.3 反向生成文件的坑

2.3.1 多次生成

一旦双击执行generate两次,第二次生成并不是覆盖,而是在原文件后面继续添加

如何判断反向生成的文件有没有问题:

  1. 打开任一xml文件,如图所示,将文件内容折叠

image-20211228092215734

  1. 折叠后的文件内容:

    这里只有一个resultMap才是正确的,如果重复出现多个id=“BaseResultMap”的resultMap,就只能把文件删掉重新生成

    image-20211228092644538

2.3.2 数据库重复命名

一旦其他数据库的别的库中也有相同命名的对象,如Team,Player等表,也会导致生成的xml文件中出现多个resultMap

如:mybatis库的文件中有了Team和player表,在ssm的反向生成文件时TeamMapper.xml和PlayerMapper.xml两个文件中都会反复生成,将mybatis这个库删除就OK了

3. 项目实例

3.1 实现分页查询

分页查询的实现逻辑:TeamExample实体类封装了查询方法,对应xml文件中的查询语句,直接调用就可以了

如下所示的:

  1. 业务层中的方法,只需要传入页数每页显示数量所有查询条件字段构建的实体类就行了
  2. 控制层中只需要调用上述方法就行了

3.1.1 逻辑业务层TeamService

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
@Service
public class TeamService {
@Resource
private TeamMapper teamMapper;
public PageInfo<Team> queryByPage(Integer pageNum, Integer pageSize, QueryVO vo) {
//多条件
TeamExample example = new TeamExample();
//创建条件的容器
TeamExample.Criteria criteria = example.createCriteria();
if (vo != null) {
if (vo.getTeamName() != null && !"".equals(vo.getTeamName().trim())) {
criteria.andTeamNameLike("%" + vo.getTeamName().trim() + "%");
}
if (vo.getChineseName() != null && !"".equals(vo.getChineseName().trim())) {
criteria.andChineseNameLike("%" + vo.getChineseName().trim() + "%");
}
if (vo.getCoach() != null && !"".equals(vo.getCoach().trim())) {
criteria.andCoachLike("%" + vo.getCoach().trim() + "%");
}
if (vo.getBeginDate() != null) {
criteria.andCreateTimeGreaterThanOrEqualTo(vo.getBeginDate());
}
if (vo.getEndDate() != null) {
criteria.andCreateTimeLessThanOrEqualTo(vo.getEndDate());
}
if (vo.getArea() != null && vo.getArea() != -1) {
criteria.andAreaEqualTo(vo.getArea());
}
}
//分页
PageHelper.startPage(pageNum, pageSize);
List<Team> list = teamMapper.selectByExample(example);
return new PageInfo<>(list);
}
}

3.1.2 控制层TeamController

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
@Controller
@RequestMapping("team")
@ResponseBody
public class TeamController {
@Resource
private TeamService teamService;
//多条件分页查询
@RequestMapping(value = "list",method = RequestMethod.GET)
public PageInfo<Team> queryByPage(Integer pageNum, Integer pageSize, QueryVO vo){
if(pageNum==null || pageNum<=0){
pageNum=1;
}
if(pageSize==null || pageSize<=0){
pageSize=5;
}
PageInfo<Team> teamPageInfo = teamService.queryByPage(pageNum, pageSize, vo);
return teamPageInfo;
}
}

3.1.3 返回结果封装类

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//返回结果的统一封装类
public class ResultVO<T> {
private PageInfo<T> pageInfo;//返回的是分页对象
private List<T> list;//返回的是集合
private T obj;//返回的是单个对象
private Integer code=200;//表示返回的状态码
private String msg="ok";//表示可以展示给用户的信息


public ResultVO() {
}

public ResultVO(Integer code, String msg) {
this.code = code;
this.msg = msg;
}

public ResultVO(PageInfo<T> pageInfo) {
this.pageInfo = pageInfo;
}

public ResultVO(List<T> list) {
this.list = list;
}

public ResultVO(T obj) {
this.obj = obj;
}
set/get方法、、、
}

3.1.4 多条件分页