java项目里面javascript打开页面时不执行,必须刷新一下才执行
java项目,使用了SSH框架,projectsearch.jsp页面显示项目列表,提交后跳转到typeanalysis.jsp,显示项目下面的具体内容,typeanalysis.jsp里面使用ichartjs做了一个饼图,但是跳转之后,js脚本不执行,必须要刷新一下才能显示,尝试了很多方法,onload方法也使用了,即便写最简单的alert也不能执行
projectsearch.jsp:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
<title>查询页面</title>
<link rel="stylesheet" href="css/jquery.mobile-1.3.0.min.css" />
<script src="js/jquery-1.9.1.min.js"></script>
<script src="js/jquery.mobile-1.3.0.min.js"></script>
</head>
<body>
<form action="typeanalysis" method="get">
<div>
<label for="projectname">项目名称:</label>
<!--<input type="text" id="fid11" name="projectId" />-->
<select name="projectId">
<%
ArrayList<Object[]> arrayList1 = (ArrayList<Object[]>) request.getAttribute("list");
for (int i = 0; i < arrayList1.size(); i++) {
Object[] object1 = arrayList1.get(i);
String projectName = object1[0].toString(); //项目名称
String projectId = object1[1].toString(); //项目ID
%>
<option value="<%=projectId%>"><%=projectName%></option>
<%
}
%>
</select>
</div>
<footer>
<input type="submit" value="提交" />
</footer>
</form>
</body>
</html>
typeanalysis.jsp:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<html>
<head>
<title>户型分析图</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="css/jquery.mobile-1.3.0.min.css" />
<script src="js/jquery-1.9.1.min.js"></script>
<script src="js/jquery.mobile-1.3.0.min.js"></script>
<script src='js/ichart.latest.min.js'></script>
<script type='text/javascript'>
$(function(){
var chart = iChart.create({
render:"ichart-render",
width:800,
height:400,
background_color:"#f4f4f4",
gradient:false,
color_factor:0.2,
border:{
color:"#bcbcbc",
width:1
},
align:"center",
offsetx:0,
offsety:0,
sub_option:{
border:{
color:"#6d869f",
width:2
},
label:{
fontweight:500,
fontsize:18,
color:"#4572a7",
sign:"square",
sign_size:20,
border:{
color:"#BCBCBC",
width:0
},
background_color:"rgba(244,244,244,0)"
}
},
shadow:true,
shadow_color:"#666666",
shadow_blur:5,
showpercent:true,
column_width:"70%",
bar_height:"70%",
radius:"90%",
title:{
text:"户型分析图",
color:"#6d869f",
fontsize:20,
textAlign:"center",
font:"微软雅黑",
height:30,
offsetx:0,
offsety:0
},
subtitle:{
color:"#111111",
fontsize:16,
textAlign:"center",
font:"微软雅黑",
height:20,
offsetx:0,
offsety:0
},
footnote:{
color:"#111111",
fontsize:12,
textAlign:"right",
font:"微软雅黑",
height:20,
offsetx:0,
offsety:0
},
legend:{
enable:false,
background_color:"#fefefe",
color:"#333333",
fontsize:12,
border:{
color:"#BCBCBC",
width:1
},
column:1,
align:"right",
valign:"center",
offsetx:0,
offsety:0
},
coordinate:{
width:"80%",
height:"84%",
background_color:"#ffffff",
axis:{
color:"#a5acb8",
width:[1,"",1,""]
},
grid_color:"#d9d9d9",
label:{
fontweight:500,
color:"#666666",
fontsize:11
}
},
label:{
fontweight:500,
color:"#666666",
fontsize:11
},
type:"pie2d",
data:[
<%
ArrayList<Object[]> arrayList1 = (ArrayList<Object[]>) request.getAttribute("list");
for(int i=0;i<arrayList1.size();i++){
Object[] object1 = arrayList1.get(i);
String roomNum = object1[0].toString(); //房间数
String roomstatus = object1[1].toString(); //房间状态
String roomstruct = object1[2]!=null?object1[2].toString():""; //房间结构
String roomtype = roomstatus+roomstruct; //房间类型
String[] color = new String[] {"rgba(254,221,116,0.9)","rgba(130,216,239,0.9)","rgba(247,104,100,0.9)","rgba(128,189,145,0.9)","rgba(253,159,193,0.9)","rgba(130,221,193,0.9)"};
System.out.println(roomtype+"@@@@@@@@@"+roomNum+"&&&&&&&&&&&&"+color[i]);
%>
{
name:"<%=roomtype%>",
value:<%=roomNum%>,
color:"<%=color[i]%>"
}
<%
if(i!=arrayList1.size()-1){
%>,<%
}
}
%>
]
});
chart.draw();
});
</script>
</head>
<body>
<div id='ichart-render'> </div>
<script>function refelsh(){location.reload();}</script>
<button onClick="refelsh();" value="刷新">刷新</button>
</body>
</html>