0
我正在研究Spring WebFlow/JSF web-app。我需要開發管理面板,管理員可以上傳一些文件,並使用這些文件作爲片段構建頁面內容。我希望我描述得很好。爲此,我創建了Spring MVC控制器,並使用如下所示的映射。它從數據庫(圖像,.xhtml)輸出文件。如何使用該控制器在頁面源上包含文件?如何在頁面源中輸出文件內容(來自數據庫)?
@RequestMapping("/file")
public void getFileContent(@RequestParam("id") Integer id, HttpServletResponse response) throws IOException {
File f = fileDAO.get(id);
response.setContentType(f.getMime());
IOUtils.write(f.getData(), response.getOutputStream());
}
這不起作用:
<ui:include src="#{request.contextPath}/app/file?id=6" />
ResourceResolver或其他地方是否有緩存?我創建了從DB獲取文件的自定義ResourceResolver,保存在'/ WEB-INF/files'中,並將url返回給這個文件。但是......我注意到''只解析了一次。數據庫中的更改對視圖沒有影響 - 不再調用「resolveUrl」方法。 –
marioosh
2011-06-17 08:03:10
我的自定義ResourceResolver:[鏈接](http://www.pastie.org/2081595) – marioosh 2011-06-17 08:17:44