配置文件
spring:
thymeleaf:
cache: false # 开发时关闭缓存,不然没法看到实时页面
mode: HTML # 用非严格的 HTML
encoding: UTF-8
servlet:
content-type: text/html
datasource:
druid:
url: jdbc:mysql://127.0.0.1/db_ls?useUnicode=true&characterEncoding=utf-8&useSSL=false
username: root
password: 123
initial-size: 1
min-idle: 1
max-active: 20
test-on-borrow: true
# MySQL 8.x: com.mysql.cj.jdbc.Driver
driver-class-name: com.mysql.jdbc.Driver
mybatis:
type-aliases-package: com.ls.qimo.mapper
mapper-locations: classpath:mapper/*.xml
配置pagehelper参数
pagehelper:
helperDialect: mysql
reasonable: true
supportMethodsArguments: true
params: count=countSql
页面必须放在templates下面
超链接 举例
<td><a th:href="@{/user/editUser(id=${user.id})}">编辑</a></td>
<td><a th:href="@{/user/deleteUser(id=${user.id})}">删除</a></td>
分页
<div>
<a th:href="@{/user/listUser(start=0)}">[首 页]</a>
<a th:href="@{/user/listUser(start=${page.pageNum-1})}">[上一页]</a>
<a th:href="@{/user/listUser(start=${page.pageNum+1})}">[下一页]</a>
<a th:href="@{/user/listUser(start=${page.pages})}">[末 页]</a>
</div>
@RequestMapping("user/listUser")
public String listCategory(Model m, @RequestParam(value = "start", defaultValue = "0")int start, @RequestParam(value = "size", defaultValue = "5") int size) throws Exception {
PageHelper.startPage(start,size,"id desc");
List<User> cs=userMapper.findAll();
PageInfo<User> page = new PageInfo<>(cs);
m.addAttribute("page", page);
return "hello";
}
这一处不知道为什么不用加模块名称test??????
https://blog.csdn.net/a450590464/article/details/43052177
action值的相对路径是指相对当前页面所在的路径或者跳转到当前页面的请求路径