springboot⽤thymeleaf模板的paginate分页完整代码本⽂根据⼀个简单的user表为例,展⽰ springboot集成mybatis,再到前端分页完整代码(新⼿⾃学,不⾜之处欢迎纠正);
先看java部分
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<!--⽀持 Web 应⽤开发,包含 Tomcat 和 spring-mvc。 -->
<dependency>      <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>      <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!--模板引擎-->
<dependency>      <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<!--Mybatis-->
<dependency>
<groupId&batis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>
1.2
.
2
</version>
</dependency>
<dependency>
<groupId&batis</groupId>
<artifactId>mybatis</artifactId>
<version>
28        29        30        31        32        33        34        35        36        37        38        39        40        41        42        43        44<version>
3.2
.
8
</version>
</dependency>
<dependency>
<groupId&ator</groupId>
<artifactId>mybatis-generator-core</artifactId> <version>
1.3
.
thyme
2
</version>
</dependency>
<!-- mybatis pagehelper -->
<dependency>
<groupId>com.github.pagehelper</groupId> <artifactId>pagehelper</artifactId>
<version>
3.6
.
3
</version>
</dependency>
<!--Mysql / DataSource-->
<dependency>
<groupId>at</groupId>
<artifactId>tomcat-jdbc</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId> </dependency>
application.properties ⽂件
启动类 Application.java
<!--springboot 集成Mybatis 所需jar 配置 end-->
1
2
3
4
5
6
7
8
9
10@SpringBootApplication @MapperScan ("com.boot.mapper")public class Application {    //定义⼀个全局的记录器,通过LoggerFactory 获取  private final static Logger logger = Logger(Application.class );
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//----------------------------mybaits配置start-------------------------------------------//DataSource
@Bean
@ConfigurationProperties
(prefix=
"spring.datasource"
)
public
DataSource dataSource() {
return
new
at.jdbc.pool.DataSource();
}
//SqlSessionFactory
@Bean
public
SqlSessionFactory sqlSessionFactoryBean()
throws
Exception {
SqlSessionFactoryBean sqlSessionFactoryBean =
new
SqlSessionFactoryBean();
sqlSessionFactoryBean.setDataSource(dataSource()); PathMatchingResourcePatternResolver resolver =
new
PathMatchingResourcePatternResolver(); sqlSessionFactoryBean.Resources( "classpath:mapper/*.xml"
));
return
}
以⼀个简单的user 对象为例
controller 层
1
2
3      private Integer id;  private String name;
private
String password;

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。