在当前的分页进行编辑删除后回到当前的分页
1.最简单的办法:
直接刷新:window.location.reload();
1 $.post( 2 "/management/delete", management2, 3 4 function () { 5 /!*$('#SaveDelete').modal('hide')*!/ 6 window.location.reload() 7 8 } 9 )
但是我用这个办法重启服务器的第一次进行编辑和删除操作时,完成了数据库数据有变化,页面强制刷新了却没变化,但是只有第一次是这样,后面都不会。
于是我用了获取页数传给controller来实现操作完成后的页面跳转。
1:先获取当前页数:
<button type="button" class="btn btn-round btn-primary" data-toggle="modal" data-target="#EditInformation" data-whatever="{{index}}" data-page="${page}">修改信息 </button>
data-page可以获取当前的页数。
把页数放到form表单中去:
$('#EditInformation').on('show.bs.modal', function (event) { var button = $(event.relatedTarget) // Button that triggered the modal var recipient = button.data('whatever') // Extract info from data-* attributes var pageindex =button.data('page') managementsindex = recipient; var modal = $(this); var management = managements[managementsindex] $("#error_null").hide(); modal.find('.modal-body input#ManagementID').val(management.managementID); modal.find('.modal-body input#ManagementName').val(management.managementName); modal.find('.modal-body input#ManagementRole').val(management.managementRole); modal.find('.modal-body input#ManagementPhone').val(management.managementPhone); modal.find('.modal-body input#ManagementPass').val(management.managementPass); modal.find('.modal-body input#pageindex').val(pageindex); })
<input id="pageindex" name="pageindex" type="hidden">
controller再接收传过来的数据和页数:
@RequestMapping(value = "/edit") public String edit( Management management1, @RequestParam(name = "pageindex") String pageindex){ managementRepository.save(management1); return "redirect:/management/show?page="+pageindex; }