本質上,我有一個servlet,它打開使用明喻時間線小部件的頁面timeline.html。 當從user.dir/timeline.html直接打開網頁時,時間線將完美顯示。 但是,當網頁由localhost:8080上的servlet打開時,它不會加載xml文件。直接打開但不打開時,直接打開但不打開時顯示的明直線時間軸
你知道爲什麼嗎?
if (action.equals("create")) {
request.getRequestDispatcher("/timeline.html").forward(request, response); }
時間軸代碼:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Timeline</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<script src="http://api.simile-widgets.org/timeline/2.3.1/timeline-api.js?bundle=true" type="text/javascript"></script>
<script>
function onLoad() {
var eventSource = new Timeline.DefaultEventSource();
var bandInfos = [
Timeline.createBandInfo({
eventSource: eventSource,
date: "Jun 28 2013 00:00:00 GMT",
width: "70%",
intervalUnit: Timeline.DateTime.MONTH,
intervalPixels: 100
}),
Timeline.createBandInfo({
overview: true,
eventSource: eventSource,
date: "Jun 28 2013 00:00:00 GMT",
width: "30%",
intervalUnit: Timeline.DateTime.YEAR,
intervalPixels: 200
})
];
bandInfos[1].syncWith = 0;
bandInfos[1].highlight = true;
tl = Timeline.create(document.getElementById("my-timeline"), bandInfos);
Timeline.loadXML("/timeline.xml", function(xml, url) { eventSource.loadXML(xml, url); });}
</script>
</head>
<body onload="onLoad();" onresize="onResize();">
<div id="my-timeline" style="height: 300px; border: 1px solid #aaa"></div>
<noscript>
This page uses Javascript to show you a Timeline. Please enable Javascript in your browser to see the full page. Thank you.
</noscript>
你會得到什麼錯誤?哪個網址適用?哪個不? – MaVRoSCy