介绍
前后端不分离项目
后端:springboot
前端:bootstraptable/ajax/Thymeleaf
BootstrapTable组件版本兼容
使用的是Bootstrap4.0版本,同时bootstrap-table的版本为V1.19.1
HTML
只需要一个配置好id的表单tag,如下:
<table id="table"></table>
后面会在js 中通过boostraptable配置table的各种属性
JS
这里我就写个大概,其中最为关键也是我搞了好半天的错误就是post和get。当时试的时候直接写了post方法,但是无法获取到数据。这里后端用的spring @Getmapping tag同时也没有指定post参数。
$table.bootstrapTable({
url: "listfile", //后端url请求地址
pagination:true,//显示分页条:页码,条数等
striped:true,//隔行变色
pageNumber:1,//首页页码
pageSize:2,
columns:[
{checkbox:true},
{filed:"index",title:"index",align:'center',formatter:function(value, row, index){
return index;
}},
{field:'fileid', title:'fileid', align:'center', visible:false},
{fiedl:'mediatypeid', title:'mediatypeid', visible:false}
}}
]
})
})