在web目录下导入所需js文件
写一个类来封装图表中所需的信息
这里封装了一个类用于统计每个班级的人数信息
public class BanjiCountVO {
private String name;
private Integer value;
public BanjiCountVO() {
}
public BanjiCountVO(String name, Integer value) {
this.name = name;
this.value = value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getValue() {
return value;
}
public void setValue(Integer value) {
this.value = value;
}
@Override
public String toString() {
return "BanjiCountVO{" +
"name='" + name + '\'' +
", value=" + value +
'}';
}
}
在Servlet中查询出对应的信息,并封装成一个集合,转化成json格式,返回给jsp页面
这里的方法是位于BanjiServlet下,jsp页面发出Ajax请求访问该方法,在方法中查询到指定数据并返回给jsp页面
private void selectBanjiCount(HttpServletRequest req, HttpServletResponse resp) {
System.out.println("BanjiServlet.selectBanjiCount");
Connection connection = null;
PreparedStatement statement = null;
ResultSet resultSet