Java中List到前台如何转成二维数组
在后台拿到了封装数据的list,在前台如何改写成这种格式?
[ [1月, 1000], [2月, 320], [3月, 640], [4月, 820], [5月, 980], [6月, 1000], [7月, 1200], [8月, 1600], [9月, 1900], [10月, 2100], [11月, 2300], [12月, 2500]]
这个是实体对象,用来封装从数据库查找出来的数据,月份和每月的记录数。
public class MotionsCount {
private int month;
private int count;
public int getMonth() {
return month;
}
public void setMonth(int month) {
this.month = month;
}
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
}
控制器调用业务层查找出数据,封装在lists中。
List<MotionsCount> lists = service.queryLists(); //这里从数据库查到了lists
问题:
如何转换成[ [1月, 1000], [2月, 320], [3月, 640], [4月, 820], [5月, 980], [6月, 1000], [7月, 1200], [8月, 1600], [9月, 1900], [10月, 2100], [11月, 2300], [12月, 2500]]
控制层使用的是springmvc,没有使用注解不能用@ResponseBody 前台使用freemarker取数据,不能使用用jstl和el表达式。求大神解救