Maven和JSF Webapp结构,确切放置JSF资源的位置 [英] Maven and JSF webapp structure, where exactly to put JSF resources
问题描述
我不太了解Maven和JSF Webapp的目录结构.
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
我想包括一些资源:
- javascript文件
- css文件
- 图片
- i18n个文件
我可以在src/main/resources
中包含i18n文件,但不能在任何地方,并且我可以在src/main/webapp/resources
中包含JS文件,CSS文件和图像,但不能在任何地方...
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...
在Web上,关于JSF和Maven的目录结构,我没有找到非常明确的规则.
I didn't find very clear rules on the web about directories structure with JSF and Maven.
请问有什么规则?
谢谢
推荐答案
要由<h:outputStylesheet>
,<h:outputScript>
和<h:graphicImage>
引用的JSF资源(因此是CSS/JS/images)应该以公开Web内容的/resources
文件夹,也位于/WEB-INF
和/META-INF
文件夹的位置.
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.
因此,您必须将它们放入/src/main/webapp/resources
.
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
这些i18n文件(从技术上来说,我认为您是指资源束文件)最终必须放在/WEB-INF/classes
中的程序包中. /src/main/resources
用于非类文件,这些文件应该以/WEB-INF/classes
结尾,您应该将它们放在这里.假设捆绑包的基本名称为com.example.i18n.text
,请按以下方式提供它们:
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
: