highcharts绘制的图片怎么都不显示?

昨天遇到了这样一个问题,从数据库查询出来数据,将数据用柱形图的方式展示到页面,可万万没想到的是,试来试去都不行,只好在网上找,查询了很多demo但是给的例子也还是行不通,该引入的js文件都引了,该导的jar包也都导入了,思前想后也没有找到答案。
这是原先的引入js的顺序:

    <script type="text/javascript" src="${pageContext.request.contextPath }/js/highcharts.js">script> 
    <script type="text/javascript" src="${pageContext.request.contextPath }/js/exporting.js">script> 
    <script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery-2.1.4.min.js">script>

highcharts.js里面依赖jquery,我把jquery放到最后一个引入的,导致了错误的发生,根本原因就在于依赖关系、执行顺序。然后更改为:

<script type="text/javascript"
    src="${pageContext.request.contextPath }/js/jquery-2.1.4.min.js">script>
<script type="text/javascript"
    src="${pageContext.request.contextPath }/js/highcharts.js">script>
<script type="text/javascript"
    src="${pageContext.request.contextPath }/js/exporting.js">script>

重启服务器,运行,结果柱形图出来了。很多小细节太容易忽视了
整个页面代码如下:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>


<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'index.jsp' starting pagetitle>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">

<script type="text/javascript"
    src="${pageContext.request.contextPath }/js/jquery-2.1.4.min.js">script>
<script type="text/javascript"
    src="${pageContext.request.contextPath }/js/highcharts.js">script>
<script type="text/javascript"
    src="${pageContext.request.contextPath }/js/exporting.js">script>

<script>
    $(function() {
        $('#container').highcharts({
            chart : {
                type : 'column'
            },

            xAxis : {
                categories : [ '一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月' ]
            },

            series : [ {
                data : [ 29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, {
                    y : 216.4,
                    color : '#BF0B23'
                }, 194.1, 95.6, 54.4 ]
            } ]
        });
    });
script>

head>
<body>
    <div id="container" style="min-width:500px;height:500px;">div>
    开发人员:爱你的贝小木
    <br>

body>
html>

你可能感兴趣的:(javaweb框架)