每次页面操作或者查询请求CURD时 响应头部都会带着页面page和rows属性。所以后台可以指定接收参数 进行分页。
SEOUDz59Kfjuf2CNxfO7bKe9pszqJrDXxOIlgKRlN+boH2ZXQ3+9fT3wetlPe02Y7H+q5PPGZfjkfWCGGkOEZhuVj+3bKh7SZ56OGPEGmAT6QFYISdgD/ghViXSE0l4Sn9+2U4p4283wQ7IAn/QMflOZ8kL+dT1BQUFBQUFBQUNC/SIJcw/din6uc2stB+SQRY5w16/5KjPwKsjUX9hBY9dFx+dggHHb3wf7KZF1B5nNhgc+6CBOSOOv+Sr9szOfCHqodm8/AmnV/pV829ufK5yP7V592o99f6ZeN+VxY8C/gk+ec1H5/5baCbM2F7XzgQX0HXTz2pyuFFWRv+YQVZG/4hBVkQUFBQUFBh1EWniXyns9x76htfCqJaHOex0LnZSmZSrsU4q/z/RHYx+ZTYniwWNxVLU9T3hWLLDWE6w98TrdLelQ+1D0/y77QSZRlU15pjWfO4qdwHce5OjwfNUxTSyYWI2wGTp72C/ayPy4f8K+Ft2jOZZNd3NMTejmYh//iQpwHfFw+qIL5GaOUD6LoBiE050Nxn3/I6UaOaT5BQUFBQUFBQYfQfwDpE67OB38NCwAAAABJRU5ErkJggg==" alt="">
例如 在初始化的时候。我们会创建一个page的 bean用来接收前台传入的page 和 row、
</span><span style="color: #0000ff;">private</span><span style="color: #000000;"> Integer page;
</span><span style="color: #0000ff;">private</span><span style="color: #000000;"> Integer rows;
</span><span style="color: #0000ff;">public</span><span style="color: #000000;"> Integer getPage() {
</span><span style="color: #0000ff;">return</span><span style="color: #000000;"> page;
}
</span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span><span style="color: #000000;"> setPage(Integer page) {
</span><span style="color: #0000ff;">this</span>.page =<span style="color: #000000;"> page;
}
</span><span style="color: #0000ff;">public</span><span style="color: #000000;"> Integer getRows() {
</span><span style="color: #0000ff;">return</span><span style="color: #000000;"> rows;
}
</span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span><span style="color: #000000;"> setRows(Integer rows) {
</span><span style="color: #0000ff;">this</span>.rows =<span style="color: #000000;"> rows;
}
}
再定义一个 pagination来方便json数组操作。
</span><span style="color: #0000ff;">private</span> List<Object><span style="color: #000000;"> rows;
</span><span style="color: #0000ff;">private</span><span style="color: #000000;"> String total;
</span><span style="color: #0000ff;">public</span><span style="color: #000000;"> List getRows() {
</span><span style="color: #0000ff;">return</span><span style="color: #000000;"> rows;
}
</span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span><span style="color: #000000;"> setRows(List rows) {
</span><span style="color: #0000ff;">this</span>.rows =<span style="color: #000000;"> rows;
}
</span><span style="color: #0000ff;">public</span><span style="color: #000000;"> String getTotal() {
</span><span style="color: #0000ff;">return</span><span style="color: #000000;"> total;
}
</span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span><span style="color: #000000;"> setTotal(String total) {
</span><span style="color: #0000ff;">this</span>.total =<span style="color: #000000;"> total;
}
}
直接调用find方法从数据库取出数据就可以了。结果会转化成json数据集然后显示在前台页面的。
牵扯到的hql关键语句为