- 新增,修改,删除数据都会使序号改动
页面jsp
//获取下一序号
$.post("${ctx}/position?method=selectNextSort",function (jsonMsg){
var nextSort=jsonMsg.data;
$('#formPosition [name="positionSort"]').val(nextSort);
});
在servlet层
/**
* 新增时获取下一排序的序号
*/
public void selectNextSort(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//调用service获取当前的总行数
int count=this.positionService.countAll();
JsonMsg jsonMsg =new JsonMsg();
jsonMsg.setState(true);
jsonMsg.setData(count+1);//下一序号=当前数据条数+1
returnJson(response,jsonMsg);
}