您的位置:首页 > 其它

如何输出动态图片

2009-02-26 22:50 225 查看
Tapestry 5 中实现就是太简单了。
在Java代码中添加
@Inject
private ComponentResources resources;
public Link getImageUrl() {
        //image 这里的image对应的后边的onImage方法哦
        return resources.createEventLink("image", photo.getFilepath());
}
public StreamResponse onImage(final String path) {
        return new StreamResponse() {
            public String getContentType() {
                return "image/jpeg";
            }
            public InputStream getStream() throws IOException {
                return new FileInputStream(path);
            }
            public void prepareResponse(Response response) {
            }
        };
    }
在tml文件中添加

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: