请帮我改一下,让数据可以动态的从数据库中获取,并在jsp页面刷新,注意页面不要刷新,只刷新数据。
<%Stringid;intdata;//创建数据集对象DefaultCategoryDatasetdataset=newDefaultCategoryDataset()...
<%
String id;
int data;
//创建数据集对象
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
//链接数据库
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/gamecount","root","root");
Statement stmt=con.createStatement();
String sql="select * from gamecount";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next())
{
id=rs.getString("gameName");
data=rs.getInt("gameData");
dataset.addValue(data,"游戏",id);
}
rs.close();
stmt.close();
con.close();
JFreeChart chart=ChartFactory.createBarChart3D("游戏投票统计", //图表标题
"互动游戏", //目录轴的显示标签
"投票数", //数值轴的显示标签
dataset, //数据集
PlotOrientation.VERTICAL, //图表方向
false, //是否显示图例
true, //是否生成工具
false); //是否生成URL链接
%> 展开
String id;
int data;
//创建数据集对象
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
//链接数据库
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/gamecount","root","root");
Statement stmt=con.createStatement();
String sql="select * from gamecount";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next())
{
id=rs.getString("gameName");
data=rs.getInt("gameData");
dataset.addValue(data,"游戏",id);
}
rs.close();
stmt.close();
con.close();
JFreeChart chart=ChartFactory.createBarChart3D("游戏投票统计", //图表标题
"互动游戏", //目录轴的显示标签
"投票数", //数值轴的显示标签
dataset, //数据集
PlotOrientation.VERTICAL, //图表方向
false, //是否显示图例
true, //是否生成工具
false); //是否生成URL链接
%> 展开
展开全部
用ajax啊
$.ajax({
type: "get", //使用get方法访问后台
dataType: "text", //返回json格式的数据
url: "Handlerimg.ashx?action=1",
contentType: "application/json",
success: function (msg) {//msg为返回的数据,在这里做数据绑定
var value = msg.split("|");
for (var i = 0; i < value.length - 1; i++) {
var s = value[i].split(":");
htmlinfo += "<tr ><td class='updateimage_td' ><a data-fancybox-group='thumb' class='fancybox-thumbs' style='color:rgb(234, 234, 234); outline:none;text-decoration:none; ' href='ImgUpload/" + s[0] + "'><img title='点击显示原图' style='height:30px;width:30px;' src='ImgUpload/" + s[0] + "'></a></td><td class='updateimage_td'>" + s[0] + "</td><td class='updateimage_td'>" + s[1] + "</td><td class='updateimage_td'>" + s[2] + "</td><td class='updateimage_td'>" + s[3] + "</td><td class='updateimage_td'>" + s[4] + "</td><td class='updateimage_td'><input imgname='" + s[0] + "' name='" + s[3] + "' imgtiaoj='" + s[1] + "' style='vertical-align:top;border:none; background-image: url(image/info.PNG);height:23px; width:60px; cursor:pointer; color:Black; font-family:微软雅黑;text-decoration:none; outline:none;' onmouseover='btnmapover(this)' onmouseout='btnmapout(this)' type='button' id='btnsub' onclick='imgupdateclick(this)' value='修改' /> </td></tr>";
}
divinfo.innerHTML = "";
divinfo.innerHTML = table + htmlinfo + "</table>";
},
error: function (a, b, c) {
alert(a.toString() + b.toString() + c.toString());
}
});
$.ajax({
type: "get", //使用get方法访问后台
dataType: "text", //返回json格式的数据
url: "Handlerimg.ashx?action=1",
contentType: "application/json",
success: function (msg) {//msg为返回的数据,在这里做数据绑定
var value = msg.split("|");
for (var i = 0; i < value.length - 1; i++) {
var s = value[i].split(":");
htmlinfo += "<tr ><td class='updateimage_td' ><a data-fancybox-group='thumb' class='fancybox-thumbs' style='color:rgb(234, 234, 234); outline:none;text-decoration:none; ' href='ImgUpload/" + s[0] + "'><img title='点击显示原图' style='height:30px;width:30px;' src='ImgUpload/" + s[0] + "'></a></td><td class='updateimage_td'>" + s[0] + "</td><td class='updateimage_td'>" + s[1] + "</td><td class='updateimage_td'>" + s[2] + "</td><td class='updateimage_td'>" + s[3] + "</td><td class='updateimage_td'>" + s[4] + "</td><td class='updateimage_td'><input imgname='" + s[0] + "' name='" + s[3] + "' imgtiaoj='" + s[1] + "' style='vertical-align:top;border:none; background-image: url(image/info.PNG);height:23px; width:60px; cursor:pointer; color:Black; font-family:微软雅黑;text-decoration:none; outline:none;' onmouseover='btnmapover(this)' onmouseout='btnmapout(this)' type='button' id='btnsub' onclick='imgupdateclick(this)' value='修改' /> </td></tr>";
}
divinfo.innerHTML = "";
divinfo.innerHTML = table + htmlinfo + "</table>";
},
error: function (a, b, c) {
alert(a.toString() + b.toString() + c.toString());
}
});
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询