效果:

重点是右边的表格,class是Bootstrap

<table><tr><td><div id="main" style="height:400px; width:500px;"></div> <!--<a target=_blank href="http://blog.csdn.net/oyuemijindu/article/details/43201155" target="_blank">左边的图</a> --></td><td><table class="table table-bordered table-condensed"><tr><td colspan="5"><h4 class="text-center">地区排行榜</h4></td></tr><tr><th colspan="3" class="text-center">总问题数排行</th><th colspan="2" class="text-center">回答率排行</th></tr><tr><td colspan="3"><table class="table table-striped table-hover table-condensed"><tr><td class="text-center">排行</td><td class="text-center">城市</td><td class="text-center">总问题数</td></tr><c:forEach items="${listsumquestion }" var="city"varStatus="stauts"><tr><td class="text-center">${stauts.index+1 }</td><td class="text-center">${city.name}</td><td class="text-center">${city.intvalue }</td></tr></c:forEach></table></td><td colspan="2"><table class="table table-striped table-hover table-condensed"><tr><td class="text-center">城市</td><td class="text-center">回答率</td></tr><c:forEach items="${listanswered }" var="city"varStatus="stauts"><tr><td class="text-center">${city.name}</td><td class="text-center" style="color:red;">${city.value }%</td></tr></c:forEach></table></td></tr></table></td></tr></table>

<c:forEach items="${listsumquestion }" var="city">这里的{ }右边多个空格就一直出错,害我把List<Map<K,V>> 改成List<javabean> 还不行,知道真相...

后台:

List<StatisticsArea> arealist = statisticsService.Statisticsarealist();List<StatisticsKeyValue> list1 = new ArrayList<StatisticsKeyValue>();List<StatisticsKeyValue> list2 = new ArrayList<StatisticsKeyValue>();for (StatisticsArea s : arealist) {StatisticsKeyValue s1 = new StatisticsKeyValue();StatisticsKeyValue s2 = new StatisticsKeyValue();s1.setName(s.getCityName());s2.setName(s.getCityName());s1.setValue(s.getSumQuestion());s1.setIntvalue((int) s.getSumQuestion());s2.setValue(s.getAnswered());list1.add(s1);list2.add(s2);}Collections.sort(list1, new ComparatorStatisticsArea());//排序Collections.sort(list2, new ComparatorStatisticsArea());request.setAttribute("listsumquestion", list1);request.setAttribute("listanswered", list2);request.setAttribute("list1", JSON.toJSONString(list1));request.setAttribute("list2", JSON.toJSONString(list2));

StatisticsKeyValue:

public class StatisticsKeyValue implements Serializable{private static final long serialVersionUID = 5739478590345876006L;/** 城市名称*/private String name;/** value*/private Double value;/** value(int)*/private int intvalue;public int getIntvalue() {return intvalue;}public void setIntvalue(int intvalue) {this.intvalue = intvalue;}public String getName() {return name;}public void setName(String name) {this.name = name;}public Double getValue() {return value;}public void setValue(double value) {this.value = value;}}

StatisticsArea:

public class StatisticsArea extends Upload implements Serializable{private static final long serialVersionUID = -5754153681356962106L;/** 城市ID */private Long id;/** 城市名称*/private String cityName;/** 问题总数*/private double sumQuestion;/** 解决数*/private double QuestionAnswered;public double getAnswered() {DecimalFormat format = new DecimalFormat("###.##");return sumQuestion > 0 ? Double.parseDouble(format.format((QuestionAnswered * 100)/ (double) sumQuestion )) : 0;}public Long getId() {return id;}public void setId(Long id) {this.id = id;}public String getCityName() {return cityName;}public void setCityName(String cityName) {this.cityName = cityName;}public double getSumQuestion() {return sumQuestion;}public void setSumQuestion(int sumQuestion) {this.sumQuestion = sumQuestion;}public double getQuestionAnswered() {return QuestionAnswered;}public void setQuestionAnswered(int questionAnswered) {QuestionAnswered = questionAnswered;}}

差点忘了排序的方法了:

private class ComparatorStatisticsArea implements Comparator<StatisticsKeyValue> {@Overridepublic int compare(StatisticsKeyValue m1, StatisticsKeyValue m2) {return -(m1.getValue().compareTo(m2.getValue()));}}

后台获取数据排序后在网页显示(Comparator)相关推荐

  1. vue+vuex+axios从后台获取数据存入vuex,组件之间共享数据

    vue+vuex+axios从后台获取数据存入vuex,组件之间共享数据 在vue项目中组件间相互传值或者后台获取的数据需要供多个组件使用的情况很多的话,有必要考虑引入vuex来管理这些凌乱的状态,今 ...

  2. 表单和ajax中的post请求后台获取数据方法(深度好文)

    最近要做后台数据接收,因为前台传来的数据太过于混乱,所以总结了一下前台数据post请求方法,顺便写了下相对应的后台接收方法. 前台主要的contenttype为下面三种:(需要注意的是请求头中data ...

  3. 使用echarts绘制统计分析图表(动态从后台获取数据)

    说明:实际项目中的统计分析模块不仅需要数据以表格的方式显示,还需要用图形化的方式进一步渲染,以提升数据的可观性,以下是使用echarts来进行绘制统计分析图表的案例: 文章目录 一.第一个静态echa ...

  4. 下拉插件 (带搜索) Bootstrap-select 从后台获取数据填充到select的 option中 用法详解...

    今天收到了客户的需求,要求在新增停车场ID的时候要从数据库查出来对应的停车场名称然后显示在界面上.保存的时候按照停车场ID进行保存. 自己首先把后台的部分写完了,测试了接口数据.成功的拿到了ajax数 ...

  5. artDialog弹窗+Ztree树从后台获取数据

    简单的ArtDialog+Ztree 样子就是这个了 学习artDialog的前去artDialog 4.1.7,我们需要的都可以在这里下载.小案例可以看这个*artDialog 4.1.7精简版* ...

  6. jsp页面加载的时候,从后台获取数据,页面加载完成之后,下拉列表中已经有值

    在jsp中,我们经常会遇到这种情况:当页面加载完成之后,下拉列表中已经有数据,这是怎么实现的呢? 下面作以详解: 1.<body οnlοad="fun()">:在js ...

  7. Vue---从后台获取数据vue-resource的使用方法

    作为前端人员,在开发过程中,我们大多数情况都需要从后台请求数据,那么在vue中怎样从后台获取数据呢?接下来,我简单介绍一下vue-resource的使用方法,希望对大家有帮助. 一.下载vue-res ...

  8. Python爬虫笔记——分析AJAX传递的JSON获取数据-初步分析动态网页

    转载文章链接: Python爬虫:分析AJAX传递的JSON获取数据-初步分析动态网页(1) [4]实战:爬取动态网页的两种思路爬取新浪趣图(1) [5]实战:爬取动态网页的两种思路爬取新浪趣图(2) ...

  9. vuex+element 从后台获取数据写导航栏-菜单权限

    主要用到 vuex.router.beforeEach.router.addRoutes().vuex 的使用方法可以看我的另一篇博客:vue笔记(四)vuex. 顺便安利一个 在线视频转gif图. ...

最新文章

  1. R语言使用zoo包中的rollapply函数计算两个时间序列数据列之间的滚动相关性(Rolling correlations)、例如,计算两种商品销售额之间的3个月的滚动相关性
  2. [jillzhang]ExtJs与WCF交互:生成树 --数据库版补充
  3. NYOJ 590 相同的和
  4. MySQL的Redolog/Undolog/binlog日志
  5. c语言接受socket发送尾部有乱码,C语言socket编程,服务器和一个客户端连接时,服务器能正常收到信息,2个以上就出现BUG了...
  6. Java编程中最容易踩雷的地方!
  7. geoserver发布瓦片_Geoserver2.15.1配置自带GeoWebCache 插件发布ArcGIS Server瓦片
  8. Leetcode: mimimum depth of tree, path sum, path sum II
  9. 江淮汽车涉嫌排放造假 罚款1.7亿
  10. group_concat 排序并取前三个
  11. 全国产化 飞腾 vpx板卡
  12. 【Redis学习笔记】redis-trib.rb命令详解
  13. linux非lvm分区在线扩容,Linux硬盘扩容(非LVM)
  14. 父级fixed_父元素设置absolute,子元素设置fixed定位失效
  15. java 抓取网页_JAVA使用爬虫抓取网站网页内容的方法
  16. 【乐通达】微信永不缺席!连发三大重磅更新,视频号终于成了视频号
  17. 关于AndroidStudio打包后apk包名乱码的问题
  18. czl蒻蒟的OI之路9
  19. python update函数会调用哪些内置函数_Python字典的内置函数中没有 append()操作,可以用 update()来更新字典内容...
  20. 看了 Google 大神 Jeff Dean 的传说,我拜服了~

热门文章

  1. 数据产品-核心能力学习
  2. 第六章 图 学习小结
  3. 《Raspberry Pi用户指南》——2.3 Debian简介
  4. MapGuide 浏览器可接受参数分析
  5. IOS开发UI篇—导航控制器属性和基本使用
  6. loadrunner11完整卸载
  7. TurboMail独家提供邮件服务器与Outlook间的地址簿同步插件
  8. checkbox设置三种状态 qt_CheckBox复选框用法及实例代码
  9. 信息学奥赛一本通 1358:中缀表达式值(expr)
  10. 信息学奥赛一本通(2070:【例2.13】数字对调)