java jsf查询数据库_java – 从数据库访问和使用.jsf文件

1: Whenever a new page has to be added/removed: manipulate the files in the classpath (e.g. remove or add a file to the .war file)

如果扩展WAR,这肯定是可能的.我不确定Jetty,但它适用于Tomcat 7和Glassfish 3上的Mojarra 2.x.只需将文件写入扩展的WAR文件夹,通常的Java IO方式就足够了.

File file = new File(servletContext.getRealPath("/foo.xhtml"));

if (!file.exists()) {

OutputStream output = new FileOutputStream(file);

try {

output.write(bytes); // Can be bytes from DB.

} finally {

output.close();

}

}

这需要在FacesServlet启动之前执行.过滤器是一个完美的地方.另见相关答案:

2: Extending the classpath of the webapplication so it will be able to get files from an at runtime defined location (i.e. /tmp or directly using a database connection)

您可以将Facelets文件打包到JAR文件中并将其放在类路径中,并提供Facelets ResourceResolver,当WAR中找不到匹配项时,它将提供来自JAR的文件.您可以在以下答案中找到完整的代码示例:

3: Provide JSF with a way to find resources another way ( this doesn’t seem possible? )

您在自定义ResourceResolver中有足够的游戏空间.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值