如果我使用out.write方法
插入js文件,它在jsp中是否正确e.g。
// generate graph
out.write("<canvas id='canvas' height='450' width='600'></canvas>");
out.write("<script>");
out.write("var barChartData = {\n");
out.write("labels : ['Pass','Fail'],\n");
out.write("datasets : [{\n");
out.write("fillColor : 'rgba(220,220,220,0.5)',\n");
out.write("strokeColor : 'rgba(220,220,220,1)',\n");
out.write("data : [65,0]},{\n");
out.write("fillColor : 'rgba(151,187,205,0.5)',\n");
out.write("data : [0,47]}]}\n");
out.write("var myLine = new Chart(document.getElementById('canvas').getContext('2d')).Bar(barChartData);\n");
out.write("</script>");
out.write("</body>\n");
out.write("</html>\n");
//Close the output stream
我在日食中得到一个错误 -
语法错误,插入“;”完成声明 - 图表无法解析 - 语法错误,插入“)”以完成MethodInvocation - 令牌“js”上的语法错误(预期在此令牌之后
)