javascript(包含在jsp中)不会呈现

时间:2012-11-13 09:18:52

标签: javascript jsp cytoscape-web

我正在尝试将javascript-tags包含到jsp文件中,但它没有呈现... 代码如下所示:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <title>Insert title here</title>
    <script language="JavaScript" src="AC_OETags.min.js"></script>
    <script language="JavaScript" src="json2.min.js"></script>
    <script language="JavaScript" src="cytoscapeweb.min.js"></script>  
    <script language="JavaScript">
        window.onload=function() {
                    // network data could alternatively be grabbed via ajax
             var xml = '\
            <graphml>\
            <key id="label" for="all" attr.name="label" attr.type="string"/>\
            <key id="weight" for="node" attr.name="weight" attr.type="double"/>\
            <graph edgedefault="undirected">\
                <node id="1"><data key="label">1</data><data key="weight">1.8</data></node>\
                <node id="2"><data key="label">2</data><data key="weight">1.1</data></node>\
                <node id="3"><data key="label">3</data><data key="weight">1.1</data></node>\
                <node id="4"><data key="label">4</data><data key="weight">1.1</data></node>\
                <node id="5"><data key="label">5</data><data key="weight">.3</data></node>\
                <node id="6"><data key="label">6</data><data key="weight">.3</data></node>\
                <edge source="1" target="2" ></edge>\
                <edge source="2" target="3" ></edge>\
                <edge source="4" target="5" ></edge>\
                <edge source="3" target="4" ></edge>\
                <edge source="6" target="5" ></edge>\
                <edge source="4" target="2" ></edge>\
                <edge source="6" target="1" ></edge>\
            </graph>\
            </graphml>\
            ';

                    // init and draw
                    // initialization options
                        var options = {
                            swfPath: "CytoscapeWeb",
                            flashInstallerPath: "playerProductInstall"
                        };

                        var vis = new org.cytoscapeweb.Visualization("cytoscapeweb", options);

                        var draw_options = {
                            // your data goes here
                            network: xml,

                            // show edge labels too
                            edgeLabelsVisible: false,

                            edgeTooltipsEnabled:true,

                            // let's try another layout
                            layout: "circle",

                            // hide pan zoom
                            panZoomControlVisible: true
                        };

                        vis.draw(draw_options);

                    };
    </script>

    <style>
        /* The Cytoscape Web container must have its dimensions set. */
        html, body { height: 100%; width: 100%; padding: 0; margin: 0; }
        #cytoscapeweb { width: 100%; height: 100%; }
    </style>
</head>
<body>
    <h1>The Graph</h1>
    <div id="cytoscapeweb">
         Cytoscape Web will replace the contents of this div with your graph.
    </div>
</body>
</html>

它使用Cytoscape Web来渲染图形。 如果我从普通的html文件中运行它,那么evereything工作得很好......

有什么建议吗?

1 个答案:

答案 0 :(得分:0)

我必须包含这样的链接:

<script language="JavaScript" src="<%@ include file="AC_OETags.min.js" %>"></script>
<script language="JavaScript" src="<%@ include file="json2.min.js" %>"></script>
<script language="JavaScript" src="<%@ include file="cytoscapeweb.min.js" %>"></script>