使用Richfaces + Spring Webflow从文件系统显示图像

时间:2011-04-15 05:47:04

标签: jsf-2 richfaces ajax4jsf spring-webflow-2

我无法使用<h:graphicImage&gt;在xhtmls中显示文件系统中的图像标签。我使用的是Spring webflow 2.0和Richfaces 3.3.3

我应该编写一个单独的servlet来提供来自文件系统的图像吗?

我调查了<a4j:mediaOutput&gt;标签 。我可以用这个吗?因为createContent要求我们指定一个将用于内容创建的方法。我不确定我们是否可以使用流变量/ bean来执行标记中的方法。

1 个答案:

答案 0 :(得分:1)

您始终可以获取位于Web Pages文件夹

下的图片
<h:graphicImage url="#{facesContext.externalContext.requestContextPath}\your_img_path_under_Web_pages" id="img" />

如果你使用<a4j:mediaOutput>标签,那么你应该在createContent中给出绘制图像的方法。

  <a4j:mediaOutput element="img" createContent="#{serviceBean.method}" value="#{dataBean}" mimeType="image/jpg" />

public void userImage(OutputStream out, Object data) throws IOException {/*your method body*/}