开发者

JSF add resources programmatically

Is there anyway to add resources to a web application using JSF programmatically? This would involve adding files in the resource folder (or any of it subfolders). I want to add a picture that can be treated as a resource so I display it with

<h:graphicImage name="name of the resource 开发者_如何学运维i create" library="subfolder under resources" />


You don't want to write to web content programmatically. It will all get lost whenever you redeploy the webapp.

Just save it to disk or DB using FileOutputStream or PreparedStatement#setBinaryStream() and then have a servlet which gets an InputStream of it from disk or DB using FileInputStream or ResultSet#getBinaryStream() respectively and then writes it to the OutputStream of the response along a proper set of HTTP response headers. Finally just call that servlet by its URL, along with the unique resource identifier or filename as request parameter or pathinfo.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜