Maven和JSF webapp结构,JSF资源到底放在哪里 [英] Maven and JSF webapp structure, where exactly to put JSF resources
问题描述
I don't really understand the structure of directories with Maven and JSF webapp.
When I generate project I have this structure :
src
|_ main
|_ java
|_ resources
|_ webapp
|_ WEB-INF
|_ web.xml
|_ index.xhtml
I want to include some resources :
- javascript file
- css file
- images
- i18n files
I can include i18n files inside src/main/resources
but not anywhere and I can include JS file, CSS file and images inside src/main/webapp/resources
but not anywhere...
I didn't find very clear rules on the web about directories structure with JSF and Maven.
What are the rules please ?
Thanks
JSF resources which are to be referenced by <h:outputStylesheet>
, <h:outputScript>
and <h:graphicImage>
(thus, CSS/JS/images), should end up in /resources
folder of the public webcontent, there where the /WEB-INF
and /META-INF
folders also are.
Thus, you've to put them in /src/main/webapp/resources
.
src
`-- main
|-- java
|-- resources
`-- webapp
|-- resources
| |-- css
| | `-- style.css
| |-- images
| | `-- logo.png
| `-- js
| `-- script.js
|-- WEB-INF
| `-- web.xml
`-- index.xhtml
Those i18n files (I assume you technically meant resource bundle files) have ultimately to end up in a package in /WEB-INF/classes
. The /src/main/resources
is intented for non-class files which are supposed to end up in /WEB-INF/classes
, you should put them in there. Assuming a bundle base name of com.example.i18n.text
, provide them as such:
src
`-- main
|-- java
|-- resources
| `-- com
| `-- example
| `-- i18n
| |-- text.properties
| |-- text_en.properties
| |-- text_es.properties
| `-- text_nl.properties
:
See also:
- How to reference CSS / JS / image resource in Facelets template?
- What is the JSF resource library for and how should it be used?
这篇关于Maven和JSF webapp结构,JSF资源到底放在哪里的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!