开发者

JSF add resources programmatically

开发者 https://www.devze.com 2023-02-19 02:17 出处:网络
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

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

精彩评论

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