有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java Tapestry动态生成图像

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

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

我尝试了一个带有StreamResponse的解决方案,但没有结果

另一个是关于IEngineService的,但似乎只适用于T4

所以,我希望能得到一些帮助。 谢谢


共 (1) 个答案

  1. # 1 楼答案

    好的,我发现问题在哪里,这里是解决方案,对于另一个类,请参见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[]{});
    }