【1】前端js调用示例:
...insertStatisData?statisDatas=[{'cid':'2','devId':'9003','deviceName':'测试名','endTime':'2016-02-11 10:00:00','enname':'flow','interval':'1','intervalType':'mi','startTime':'2016-02-11 10:00:00','value':'33'},{'cid':'2','devId':'9004','deviceName':'测试名2','endTime':'2016-02-11 10:00:00','enname':'flow','interval':'1','intervalType':'mi','startTime':'2016-02-11 10:00:00','value':'22'}]
【2】Controller层函数接收:
Gson gson = new Gson();
List<StatisData> list = gson.fromJson(statisDatas, new TypeToken<List<StatisData>>() {}.getType());//将数据串转换为数据对象list
//要保证传入的json字符串statisDatas的格式为pojo:StatisData的字段对应
【3】注意:Controller层引入jar包
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;