当前位置: 移动技术网 > IT编程>开发语言>JavaScript > echarts请求流量分析统计

echarts请求流量分析统计

2020年07月14日  | 移动技术网IT编程  | 我要评论

项目知识
Echarts
ajax
Json
Jquery
监听器ServletContextListener,ServletRequestListener

项目收获
时间格式化
Date date=new Date();
SimpleDateFormat sdf= new SimpleDateFormat(“HH:mm”);
String time=sdf.format(date);
入门echarts(直接搜便可)图标展现echarts.min.js

项目步骤
一.创建监听器类ServletContextListener,ServletRequestLostener。(配置

包名.类名


在ServletContextListener中存入两个List(timeList,valueList),存入ServletContext
在ServletRequestListener中
//将/rt排出请求统计范围内
HttpServletRequest request=(HttpServletRequest)sre.getServletRequest();
String url=request.getRequestURL().toString();
If(url.endsWith(“/rt”)==ture){
Return;
}endswith()当前字符串是以。。。结尾的

List timeList=(List)sre.getServletContext().getAttribute(“timeList”);和valueList
Date date=new Date();
SimpleDateFormat sdf=new SimpleDateFormat(“HH:mm”);
String time=sdf.format(date);
If(timeList.indexOf(time)==-1){
timeList.add(time);
valueList.add(1);
Sre.getServletContext().setAttribute(“timeList”,timeList);
Sre.getServletContext().setAttribute(“valueList”,valueList);
}else{
Int index=timeList.indexOf(time);
Int value=valueList.get(index);
valueList.set(index,value+1);
Sre.getServletContext().setAttribute(“valueList”,valueList);

}
二.建立3个页面.html
建立RequestTotalServlet类,接收ServletContext的timeList,valueList。
Response.setContentType(“text/html;charset=utf-8”);
Map result=new HashMap();
Result.put(“timeList”,timeList);
Result.put(“valueList”,timeList);
String json=JSON.toJSONString(result);
Response.getWriter().println(json);
三.写ajax和echarts
导入jquery和echarts.min.js

}
})

}
Window.setInterval(“showChart()”,1000);

本文地址:https://blog.csdn.net/weixin_46176142/article/details/107279723

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网