【问题标题】:Tapestry dynamic generated imageTapestry 动态生成图像
【发布时间】:2010-08-16 09:45:50
【问题描述】:

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

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

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

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

所以,我将不胜感激。 谢谢。

【问题讨论】:

    标签: java jfreechart tapestry


    【解决方案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[]{});
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-08-16
      • 2011-03-31
      • 2012-04-21
      • 2023-03-04
      • 2011-01-03
      • 2011-11-24
      • 2017-11-10
      • 1970-01-01
      相关资源
      最近更新 更多