我有一个JSP页面,随后会调用多个jQuery.getJSON()
函数。我渲染一些图表,一切都很好。用户单击菜单项(URL)以调用此JSP页面。
getJSON函数和处理脚本在$(document).ready(function()...
但是,登录后用户被重定向到同一页面时,这些功能将无法执行。我想我必须遗漏一些关于Ajax或jQuery的基本信息,但是经过几个小时的网络搜索后我找不到答案。
这是JSP文件:
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ page import="org.apache.struts.Globals" %>
<%
/*
* Dashboard Main Page
*
* Version History:
*
* Initial version.
*
*/
%>
<html:html locale="true">
<%@include file="/pages/include_skillsauction_header.html"%>
<body>
<head>
<script language="javascript" type="text/javascript">
function changeDivHTML()
{
document.getElementById('chart-container-1').innerHTML = "<img src='/apvbase/img/ajax-loader.gif'/>";
}
</script>
<script type="text/javascript" src="../../js/jquery.js"></script>
<script type="text/javascript" src="../../js/highcharts.js"></script>
<script type="text/javascript" src="../../js/themes/grid.js"></script>
<script>
$(document).ready(function()
{
$(function()
{
// ---
$.getJSON('../../JScriptUtils.do?method=getProjectRisks', function(arr)
{
chartRisks = new Highcharts.Chart({
chart: {
renderTo: 'chart-container-1',
defaultSeriesType: 'column',
borderWidth: 2
},
title: {
text: 'Project Risk Profile'
},
subtitle: {
text: 'All Open Risks by Project'
},
tooltip: {
formatter: function() {
return ''+
this.x +': '+ this.y +' logins';
}
},
xAxis:
{
categories: arr.name,
labels: {
rotation: -45,
align: 'right',
style: {
font: 'normal 8px Verdana, sans-serif'
}
}},
yAxis: {
min: 0,
max: 50,
title: {
text: 'Risks'
},
tickInterval: 10
},
series: [
{ data: arr.data,
dataLabels: {
enabled: true,
formatter: function() {
return this.y;
}
},
name: 'Risks Raised'
}
]
});
});
// +++
}); // function()
}); // ready()
</script>
</head>
<div id="document">
<%@include file="/pages/include_recruiter_header.jsp"%>
<div id="main">
<div id="content-section">
<div id="contentsNoSideBar">
<!-- Display Login details -->
<h2><bean:message key="recruiter.provFeedback.heading"/></h2>
<p>
<table>
</tr>
<td>
<div id="chart-container-1" style="width: 34%; height: 300px"></div>
</td>
</tr>
</table>
</div>
</div>
</div>
<div id="siteInfo">
<%@include file="/pages/include_standard_footer.jsp"%>
</div>
</div>
<script>
// Display the spinner icon until ready ..
changeDivHTML();
</script>
</body>
</html:html>
非常感谢任何帮助。
答案 0 :(得分:3)
好的 - 是的,因为上下文路径是硬编码的。为了解决这个问题,我将../js/jquery.js
之类的任何引用替换为src="<%=request.getContextPath()%>/js/jquery.js">
现在它有效..希望我没有浪费任何人的时间。