final ArrayList ids = new ArrayList<>();
List nameList = new ArrayList<>();
List price1List = new ArrayList<>();
List price2List = new ArrayList<>();
List amountList = new ArrayList<>();
for (Goods goods : goodsList) {
final Integer id = goods.getId();
ids.add(id);
final String name = goods.getName();
nameList.add(name);
final double price1 = goods.getPrice1();
price1List.add(price1);
final double price2 = goods.getPrice2();
price2List.add(price2);
final Integer amount = goods.getAmount();
amountList.add(amount);
}
final JSONObject jsonObject = new JSONObject();
jsonObject.put(“ids”, ids);
jsonObject.put(“nameList”, nameList);
jsonObject.put(“price1List”, price1List);
jsonObject.put(“price2List”, price2List);
jsonObject.put(“amountList”, amountList);
response.getWriter().write(jsonObject.toString());
}
}
-
下载并导入jquery.min.js文件
-
下载并导入 echarts.min.js 文件
-
bar.jsp页面
<%@ page contentType=“text/html;charset=UTF-8” language=“java” %>
- pie.jsp页面
<%@ page contentType=“text/html;charset=UTF-8” language=“java” %>