最近项目中有一个需求分页查询数据,并在各页勾选相应的checkbox框进行保存。项目采用的是layui+mybatis+mysql+springboot实现。实现思路:定义一个存储用户ID的数组,监听表单checkbox将选中的角色ID放入数组和取消的角色ID删除。页面初始化时通过layui的parseData将选中的角色ID放入用户ID数组中。jsp页面<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
Controller @ResponseBody
@RequestMapping(value = "/getOperativeRoleMapList")
public void getOperativeRoleMapList(HttpServletRequest request, HttpServletResponse response, PageParam pageParam) throws Exception
{
Page pager = new Page();
pager.setPage(pageParam.getPage());
pager.setRecPerPage(pageParam.getLimit());
PageData