2

我的 Tapestry5 应用程序每天都使用 jFreeChart 动态生成图像。我的问题是我不知道如何展示。

我试图将它们保存到 webapp 文件夹中,但似乎不可能,里面没有创建文件。

我尝试了使用 StreamResponse 的解决方案,但没有结果。

另一个是关于 IEngineService 但它似乎只适用于 T4。

所以,我会很感激一些帮助。谢谢。

4

1 回答 1

3

好的,我发现问题出在哪里,这里是解决方案,对于其他类,请参阅Tapestry5: How To Stream An Existing Binary File

public StreamResponse onImage() {
    StreamResponse result = null;
    if (graphic != null && graphic.getImage() != null) {
        try {
            InputStream input = new FileInputStream(graphic.getImage());
            result = new PngInline(input, "test");
        } catch (FileNotFoundException e) {
            logger.error("Loading graphic image", e);
        }
    }
    return result;
}
@Inject
private ComponentResources resources;

public Link getLink() {
    return resources.createEventLink("image", new Object[]{});
}
于 2010-08-16T12:29:27.430 回答