gpt4 book ai didi

java - JSP页面无法显示3D饼图

转载 作者:行者123 更新时间:2023-12-01 15:04:41 27 4
gpt4 key购买 nike

正如标题所说,即使保存了图像,我也无法在JSP页面上显示3D饼图。我尝试了绝对路径和相对路径,但仍然不起作用。有人可以帮忙解决吗这个问题?

这里是源代码:
AnalyticsUserClient.jsp(Java代码)

DefaultPieDataset pieDataset = new DefaultPieDataset(); 
BufferedReader bReader =new BufferedReader(new FileReader("C:/Users/L31207/Desktop/eclipse-jee-juno-win32/eclipse/user.txt"));
String s;
while ((s=bReader.readLine())!=null){
String datavalue [] = s.split("\t");
String category = datavalue[0];
String value = datavalue [1];
pieDataset.setValue(category, Double.parseDouble(value));
}
bReader.close();

JFreeChart chart = ChartFactory.createPieChart3D(
"Percentage of Each Category for User", pieDataset, true, true, true);

PiePlot3D p = (PiePlot3D) chart.getPlot();
p.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{0}: {2}"));
p.setForegroundAlpha(0.5f);
p.setBackgroundAlpha(0.2f);

chart.setBackgroundPaint(Color.white);
chart.setAntiAlias(true);
chart.setBorderVisible(false);
chart.setTextAntiAlias(true);

try {
ChartUtilities.saveChartAsPNG(new File("C:/Users/L31207/Desktop/eclipse-jee-juno-win32/eclipse/AnalyzeUser.png"), chart, 800, 600);
} catch (IOException e) {
e.printStackTrace();
System.err.println("Problem occurred creating chart.");
}

AnalyzeUserClient.jsp(HTML代码)

<img src="C:/Users/L31207/Desktop/eclipse-jee-juno-win32/eclipse/AnalyzeUser.png" height="500px" width="500px" usemap="#chart">

最佳答案

<img src="..."/>需要引用客户端(与服务器不在同一台计算机上运行的浏览器)可以访问的资源。 href 的情况并非如此。指向 C: 上的文件驾驶。您需要提供对该文件中存储的图像的 HTTP 访问权限。

关于java - JSP页面无法显示3D饼图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13132015/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com