easyui+ssm 带分页表格
来源:互联网 发布:拦沙坝计算软件 编辑:程序博客网 时间:2024/06/06 05:00
序:
框架:ssm+easyui
项目构建:maven
分页工具:pageHelper
第一步 引入easyui
<link rel="stylesheet" type="text/css" href="js/jquery-easyui-1.4.1/themes/default/easyui.css" />
<link rel="stylesheet" type="text/css" href="js/jquery-easyui-1.4.1/themes/icon.css" />
<link rel="stylesheet" type="text/css" href="css/taotao.css" />
<script type="text/javascript" src="js/jquery-easyui-1.4.1/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery-easyui-1.4.1/jquery.easyui.min.js"></script>
<script type="text/javascript" src="js/jquery-easyui-1.4.1/locale/easyui-lang-zh_CN.js"></script>
第二步 在jsp文件中,创建table
<table class="easyui-datagrid" id="itemList" title="商品列表"
data-options="singleSelect:false,collapsible:true,pagination:true,url:'/item/list',method:'get',pageSize:30,toolbar:toolbar">
<thead>
<tr>
<th data-options="field:'ck',checkbox:true"></th>
<th data-options="field:'id',width:60">商品ID</th>
<th data-options="field:'title',width:200">商品标题</th>
<th data-options="field:'cid',width:50">叶子类目</th>
<th data-options="field:'sellPoint',width:240">卖点</th>
<th data-options="field:'price',width:70,align:'right',formatter:TAOTAO.formatPrice">价格</th>
<th data-options="field:'num',width:70,align:'right'">库存数量</th>
<th data-options="field:'barcode',width:100">条形码</th>
<th data-options="field:'status',width:60,align:'center',formatter:TAOTAO.formatItemStatus">状态</th>
<th data-options="field:'created',width:130,align:'center',formatter:TAOTAO.formatDateTime">创建日期</th>
<th data-options="field:'updated',width:130,align:'center',formatter:TAOTAO.formatDateTime">更新日期</th>
</tr>
</thead>
</table>
解释: data-options中
singleSelect:false 为鼠标点击该行,该行不会被自动勾选(如果有复选框的话)
collapsible:true 能够收缩
pagination:true 翻页
url:'/item/list' 后台访问地址
method:'get' 访问方式
pageSize:30 默认每页30条记录数
toolbar:toolbar 工具
第二步 编写pojo类(属性名称与表格内的name名称一致)
item实体类
public class Item implements Serializable{
private Long id;
private String title;
private String sellPoint;
private Long price;
private Integer num;
private String barcode;
private String image;
private Long cid;
private Byte status;
private Date created;
private Date updated;
get/set方法(略)
}
PageVo类
public class PageVo implements Serializable{
private Integer page; //当前页
private Integer rows; //当前页的记录数
}
包装vo类(这个类是最终返回给页面的)
public class EasyUIResult implements Serializable{
private long total; //总记录数
private List<?> rows;//二维数组 装载数据
}
第三步 编写controller层
@Controller
public class ItemController {
@Autowired
private ItemService itemService;
@RequestMapping("/item/list")
@ResponseBody
public EasyUIResult findEasyUiResult(PageVo pv){
EasyUIResult easyUiResults = itemService.findEasyUiResult(pv);
return easyUiResults;
}
}
第四步 编写service层
public interface ItemService {
EasyUIResult findEasyUiResult(PageVo pv);
}
第五步 编写serviceImpl实现层 这也是分页处理
@Service
@Transactional
public class ItemServiceImpl implements ItemService {
@Autowired
private ItemMapper itemMapper;
@Override
public EasyUIResult findEasyUiResult(PageVo pv) {
PageHelper.startPage(pv.getPage(),pv.getRows());
List<Item> list = itemMapper.findEasyUiResult();
//取分页信息
PageInfo<Item> pageInfo = new PageInfo<>(list);
//创建返回结果对象
EasyUIResult result = new EasyUIResult();
result.setRows(list);
result.setTotal(pageInfo.getTotal());
return result;
}
}
第六步 mapper层
public interface ItemMapper {
public List<Item> findEasyUiResult();
}
第七步 mapper映射xml文件
<mapper namespace="mapper文件的全限定名">
<select id="findEasyUiResult" resultType="item实体类的全限定名">
select 需要查询的属性名 from item
</select>
</mapper>
(完结)
- easyui+ssm 带分页表格
- easyui 分页表格插件带搜索
- SSM+easyUi分页
- SSM + EasyUI 分页
- ssm+easyUI之分页查询
- easyUI 数据表格客户分页
- ssm结合easyui做分页查询
- SSM+EasyUI分页脚本简用
- Drupal生成表格带分页
- Jquery EasyUI操作表格,分页显示
- easyui datagrid local pager 表格本地分页
- easyui-table表格客户端分页实例
- SSM+easyUI结合Mybatis-PageHelper实现分页功能
- angular表格带筛选分页,本地json
- easyui的自动分页表格以及行编辑模式edatagrid
- jQuery easyUi 数据表格DataGrid 分页查询及常见问题解析
- easyui combogrid下拉表格的分页/按键/动态搜索
- EasyUI DataGrid表格分页效果实现—笔记
- 使用patch接口连接两个ovs网桥
- LINUX(3)
- create git
- POJ 3278 Catch That Cow-模拟
- Openssl中的Libssl API
- easyui+ssm 带分页表格
- LayaAir 实现用获取本地JSON数据资源并循环列出
- 隐式启动Service
- AI 技术与伦理
- centos rpm方式安装mysql
- Maven学习笔记(六)——Maven插件
- 栈的链式存储实现c语言
- BRIEF描述子算法学习
- Java第二天