前台主要代码:
后台commit接收类:
//设置请求编码req.setCharacterEncoding("UTF-8");//获取编辑数据 这里获取到的是json字符串String deleted = req.getParameter("deleted");String inserted = req.getParameter("inserted");String updated = req.getParameter("updated");if(deleted != null){ //把json字符串转换成对象 ListlistDeleted = JSON.parseArray(deleted, Bean.class); //TODO 下面就可以根据转换后的对象进行相应的操作了}if(inserted != null){ //把json字符串转换成对象 List listInserted = JSON.parseArray(inserted, Bean.class);}if(updated != null){ //把json字符串转换成对象 List listUpdated = JSON.parseArray(updated, Bean.class);}
Bean.java
public class Bean { private String code; private String name; private Double price; public String getCode() { return code; } public void setCode(String code) { this.code = code; } public String getName() { return name; } public void setName(String name) { this.name = name; } public Double getPrice() { return price; } public void setPrice(Double price) { this.price = price; }}