【问题标题】:Accessing variable from properties file in JSF [duplicate]从JSF中的属性文件访问变量[重复]
【发布时间】:2018-07-31 23:36:18
【问题描述】:

我的项目中有属性文件,其中放置了所有 URL 和其他配置属性。

我想在.xhtml 页面中使用一个网址。我尝试了很多东西,但都没有成功。

下面是我的 JSF 页面:

<ui:composition template="/WEB-INF/templates/mainlayout.xhtml"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:f="http://xmlns.jcp.org/jsf/core"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
                xmlns:a="http://xmlns.jcp.org/jsf/passthrough"
                xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
                xmlns:p="http://primefaces.org/ui"
                xmlns:pe="http://primefaces.org/ui/extensions">
  <ui:define name="content">
    <div id="iFrameContainer">
        <iframe  width="100%" 
                 height="100%" 
                 frameborder="0" 
                 src="http://testURL">
        </iframe>
    </div>

  </ui:define>

</ui:composition>

testURL是我要使用属性文件URL参数的地方。

【问题讨论】:

  • 例如“我尝试了很多东西但没有成功”?
  • 上一个评论是对的,见How to Ask

标签: jsf


【解决方案1】:

在你的faces-config.xml 添加:

<resource-bundle>
  <base-name>package.name_of_properties_file</base-name>
  <var>props</var>
</resource-bundle>  

然后,您可以在facelets 文件中使用它:

 <div id="iFrameContainer">
    <iframe  width="100%" 
             height="100%" 
             frameborder="0" 
             src="#{props['textUrl']}"
             >
    </iframe>
</div>

【讨论】:

  • @thanks 但是什么是“味精”?
  • @Talib 对不起...这是一个错字。现在改正了
猜你喜欢
  • 2011-08-25
  • 2013-01-23
  • 2017-12-03
  • 2012-03-15
  • 2012-11-28
  • 2017-06-25
  • 1970-01-01
  • 2012-05-05
  • 2012-05-08
相关资源
最近更新 更多