2013-06-27 5 views
2

기본적으로 나는 우연한 타임 라인 위젯을 사용하는 timeline.html 페이지를 여는 서블릿을 가지고 있습니다. 웹 페이지가 user.dir/timeline.html에서 직접 열리면 타임 라인이 완벽하게 표시됩니다. 그러나 웹 페이지가 localhost : 8080에서 서블릿에 의해 열리면 xml 파일이로드되지 않습니다.Simile 타임 라인은 직접 열었을 때 열지 만 서블릿으로 열지 않은 경우에만 표시됩니다.

이유가 궁금하십니까?

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> 

+0

어떤 오류가 발생합니까? 어떤 URL이 작동합니까? 어느 쪽이 아니야? – MaVRoSCy

답변

2

/timeline.xml이 당신의 웹 어플리케이션 컨텍스트 루트 위치를 나타냅니다. xml 파일을 루트 위치에 놓고 있습니까? 예를 들어 myapp이라는 웹 응용 프로그램을 webapps/myapp에 배포 한 경우 '/'은 myapp 디렉토리를 나타냅니다. 따라서 /timeline.xmlmyapp/timeline.xml을 말합니다.

+0

그래도 /timeline.xml 대신 timeline.xml을 사용하여 해결했습니다. – Jean