- Java EE 8 Application Development
- David R. Heffelfinger
- 200字
- 2021-07-02 22:04:59
Standard resource locations
JSF 2.0 introduced standard resource locations. Resources are artifacts a page or JSF component needs to render properly. Resource examples include CSS stylesheets, JavaScript files, and images.
In JSF 2.0 and newer versions, resources can be placed in a subdirectory under a folder called resources, either at the root of the WAR file or under its META-INF directory. By convention, JSF components know they can retrieve resources from one of these two locations.
In order to avoid cluttering the resources directory, resources are typically placed in a subdirectory. This subdirectory is referred to from the library attribute of JSF components.
For example, we could place a CSS stylesheet called styles.css under /resources/css/styles.css.
In our JSF pages, we could retrieve this CSS file using the <h:outputStylesheet> tag, as follows:
<h:outputStylesheet library="css" name="styles.css"/>
The value of the library attribute must match the subdirectory where our stylesheet is located.
Similarly, we could have a JavaScript file under /resources/scripts/somescript.js and an image under /resources/images/logo.png, and we could access these resources as follows:
<h:graphicImage library="images" name="logo.png"/>
And:
<h:outputScript library="scripts" name="somescript.js"/>
Notice that, in each case, the value of the library attribute matches the corresponding subdirectory name under the resources directory, and the value of the name attribute matches the resource's file name.
- VMware View Security Essentials
- Java系統分析與架構設計
- Java完全自學教程
- Getting Started with SQL Server 2012 Cube Development
- Modular Programming in Java 9
- Extreme C
- LabVIEW虛擬儀器程序設計從入門到精通(第二版)
- Mastering Apache Storm
- 從Excel到Python數據分析:Pandas、xlwings、openpyxl、Matplotlib的交互與應用
- 貫通Tomcat開發
- 程序員必會的40種算法
- JavaScript Concurrency
- Flask開發Web搜索引擎入門與實戰
- JavaScript Mobile Application Development
- Python繪圖指南:分形與數據可視化(全彩)