2011-04-15 57 views
0

我無法使用<h:graphicImage>標記在xhtmls中顯示來自文件系統的圖像。我正在使用Spring Webflow 2.0和Richfaces 3.3.3從文件系統使用Richfaces + Spring Webflow顯示圖像

我應該編寫一個單獨的servlet來爲文件系統中的圖像提供服務嗎?

我看着<a4j:mediaOutput>標籤。我可以使用這個嗎?因爲createContent要求我們指定一個將用於內容創建的方法。我不確定我們是否可以使用流變量/ bean來執行標記中的方法。

回答

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*/}