标签:
以前做的东西,怕忘了随手做一个记录
首先在配置数据库连接字符串后面加上
&allowMultiQueries=true
我的完整的是这样的 jdbc:mysql://192.168.1.200:3306/huasheng?characterEncoding=utf-8&allowMultiQueries=true
Controller层把一个JSON字符串转换成list集合
@RequestMapping(value = "/update")
public@ResponseBody DataMess update(String data){
DataMess dm=new DataMess();
List<Torderdetail> list = new ArrayList<Torderdetail>();
try {
JSONArray obj=JSONObject.parseArray(data);
Iterator<Object>jos = obj.iterator();
while(jos.hasNext()){
JSONObject oj=(JSONObject) jos.next();
Torderdetail orderdetail = new Torderdetail();
orderdetail.setGoodsid(Integer.parseInt(oj.get("goodsid").toString()));
orderdetail.setGoodsnumber(Integer.parseInt(oj.get("goodsnumber").toString()));
list.add(orderdetail);
}
orderDetailService.update(list);
dm.setSuccess(true);
} catch (Exception e) {
dm.setMessage("失败");
dm.setSuccess(false);
LogUtil.doErr("修改出错");
}
return dm;
}
配置文件我是这样写的 (Oracle好像不太一样,这只是mysql的配置)
<update id="update" parameterType="java.util.List">
<foreach collection="list" item="item" index="index" open="" close="" separator=";">
update tb_orderdetail
<set>
goodsnumber=${item.goodsnumber}
</set>
where orderdetailid = ${item.goodsid} and orderId = 0
</foreach>
</update>
标签:
原文地址:http://www.cnblogs.com/gengyixing/p/5179402.html