jdbcUrl=jdbc:mysql://localhost:8080/dbname?characterEncoding=UTF-8&allowMultiQueries=true
注: 加上allowMultiQueries=true 才能支持多条的(以分号 ‘;’隔开)SQL执行。
{
"macList": [{
"macid": 1,
"age": 45,
"number": 3
}, {
"macid": 3,
"age": 24,
"number": 56
}]
}
public class MacVO implements Serializable {
//.....
private List macList; //和前端传来的名称要对应,注意List中的元素是Mac对象
//..... 省略set get
}
注:属性名macList是对应JSON的key名称,List中的元素是Mac对象
public class Mac implements Serializable {
//.....
private Integer macid;
private Integer age;
private Integer number;
private String name;
private String hobby;
//..... 省略set get
}
@RequestMapping(value = "/updateMacMsg",method = RequestMethod.POST,produces = "application/json;charset=UTF-8")
@ResponseBody
public Object updateMacMsg(@RequestBody MacVO macVO) {
//...
int rows = macService.updateMacMsg(macVO);
//...
return obj;
}
public Integer updateMacMsg(MacVO macVO);
update Table_Name
MAC_AGE = #{obj.age,jdbcType=INTEGER},
MAC_NUMBER = #{obj.number,jdbcType=INTEGER},
AND MAC_ID = #{obj.macid,jdbcType=INTEGER},
AND MAC_AGE = #{obj.age,jdbcType=INTEGER},
AND MAC_NUMBER = #{obj.number,jdbcType=INTEGER},
注:
collection="macList"中的macList是MacVO对象的macList属性。
前端JOSN对象在VO用List集合来接收,所以SQL中要对List中每个元素对象进行更新操作,用