- a标签访问request等,如果直接在url中拼接是不行的,不允许访问,如:
//控制器
@GetMapping
public String index(@RequestParam(value = "page", defaultValue = "1") Integer page,
@RequestParam(value = "limit", defaultValue = "10") Integer limit,
@RequestParam(value = "user_id", required = false) Integer userId,
Model model
) {
PageInfo<Trade> list = service.findByPage(page, limit, userId);
if (list.getList().size() == 0) {
return "admin/404";
}
model.addAttribute("list", list);
return path + "/index";
}
<a th:href="${'/admin/trade?page='+page}">test</a>
,这里page、limit、user_id是不允许访问的(在普通标签中可用,如:<div th:text="${page}">test</div>
),会报错,只能通过下面这种方式来访问
<div class="layui-box layui-laypage layui-laypage-default" id="layui-laypage-1">
<a th:href="@{'/admin/trade'(page=${list.getPrePage()},user_id=${#request.getParameter('user_id')})}"
class="layui-laypage-prev"
th:classappend="${list.isHasPreviousPage()?'':'layui-disabled'}">
<i class="layui-icon"></i>
</a>
<a th:href="@{'/admin/trade'(page=${page},user_id=${#request.getParameter('user_id')})}"
th:each="page : ${list.getNavigatepageNums()}"
th:classappend="${list.getPageNum()==page?'layui-laypage-curr':''}">
<em class="layui-laypage-em"></em><em th:text="${page}">1</em>
</a>
<a th:href="@{/admin/trade(page=${list.getNextPage()},user_id=${#request.getParameter('user_id')})}"
class="layui-laypage-next"
th:classappend="${list.isHasNextPage()?'':'layui-disabled'}">
<i class="layui-icon"></i>
</a>
</div>