使用 Struts2 在网页中显示 JFreeChart

2023-12-15

我使用的是Struts2。我需要在网页中显示 JFreeChart。有人可以帮助我吗?

编辑:它以二进制格式显示。

public String execute() throws Exception {
    System.out.println("Refresh bar Chart");
    response.setContentType("image/png");
    OutputStream outstream = response.getOutputStream();
    try {
        JFreeChart chart = getChartViewer();
        ChartUtilities.writeChartAsPNG(outstream, chart, 500, 300);
        System.out.println("Created bar Chart");
        return SUCCESS;
    } finally {
        outstream.close();
        response.flushBuffer();
    }
}

您可以将图表转换为图像并将其包含在 HTML 文件中。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用 Struts2 在网页中显示 JFreeChart 的相关文章

随机推荐