这是我的代码段
这是我的form.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<h1>Beer Selection Page</h1>
<form method="post" action="SelectBeer.do">
Select beer characteristics
<p>
Color: <select name="color" size="1">
<option value="light">light</option>
<option value="amber">amber</option>
<option value="brown">brown</option>
<option value="dark">dark</option>
</select> <br>
<br>
<input type="submit" value="Submit Beer" >
</form>
<form action="BandwidthCalc.do">
<br>
<br>
<input type="submit" value="Calculate Bandwidth" >
</form>
</body>
</html>
这是我的BandwidthCalc.java servlet类
public class BandwidthCalc extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
RequestDispatcher view = request.getRequestDispatcher("bandwidth.jsp");
view.forward(request, response);
}
}
这是我的bandwidth.jsp文件
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Bandwidth calculation</title>
</head>
<body>
This is bandwidth page!! <br>
<script src="./js/jquery-2.1.3.min.js" type="text/javascript"></script>
<script src="./Boomerang/boomerang.js" type="text/javascript"></script>
<script src="./js/testBeacon.js" type="text/javascript"></script>
<div id="results">
</div>
</body>
</html>
这是我的testBeacon.js文件
var bw=null,be=null,lat=null,laterr=null;
BOOMR.init({
user_ip: '127.0.0.1',
});
BOOMR.subscribe('before_beacon', function(o) {
var html = "", t_name, t_other, others = [];
if(!o.t_other) o.t_other = "";
for(var k in o) {
if(!k.match(/^(t_done|t_other|bw|lat|bw_err|lat_err|u|r2?)$/)) {
if(k.match(/^t_/)) {
o.t_other += "," + k + "|" + o[k];
}
else {
others.push(k + " = " + o[k]);
}
}
}
if(o.t_done) { html += "This page took " + o.t_done + " ms to load<br>"; }
if(o.t_other) {
t_other = o.t_other.replace(/^,/, '').replace(/\|/g, ' = ').split(',');
html += "Other timers measured: <br>";
for(var i=0; i<t_other.length; i++) {
html += " " + t_other[i] + " ms<br>";
}
}
if(o.bw) { html += "Your bandwidth to this server is " + parseInt(o.bw*8/1024) + "kbps (±" + parseInt(o.bw_err*100/o.bw) + "%)<br>"; }
if(o.lat) { html += "Your latency to this server is " + parseInt(o.lat) + "±" + o.lat_err + "ms<br>"; }
var r = document.getElementById('results');
r.innerHTML = html;
if(others.length) {
r.innerHTML += "Other parameters:<br>";
for(var i=0; i<others.length; i++) {
var t = document.createTextNode(others[i]);
r.innerHTML += " ";
r.appendChild(t);
r.innerHTML += "<br>";
}
}
});
当我运行此BOOMR.subscribe函数时,没有执行。我不明白为什么?我已经使用链接http://github.com/lognormal/boomerang/
包含了Boomerang文件夹答案 0 :(得分:0)
你使用没有任何插件的回旋镖,所以它不会运行。自述文件在顶部附近有以下文本:
您必须至少包含一个插件(它不必是rt),否则将永远不会实际调用信标。
https://github.com/lognormal/boomerang/blob/master/README.md