The folder name is fixed as per chapters 2.6.1.1 and 2.6.1.2 of the JSF specification.
2.6.1.1 Packaging Resources into the Web Application Root
The default implementation must support packaging resources in the web application root
under the path
resources/<resourceIdentifier>
relative to the web app root. Resources packaged into the web app root must be accessed using the getResource*()
methods on ExternalContext.
2.6.1.2 Packaging Resources into the Classpath
For the default implementation, resources packaged in the classpath must reside under the
JAR entry name:
META-INF/resources/<resourceIdentifier>
Resources packaged into the classpath must be accessed using the getResource*()
methods of the ClassLoader
obtained by calling the getContextClassLoader()
method of the current Thread
.
どちらの場合も「しなければならない」と述べています。これらのパスを変更するための可能な構成オプションについては何も言及されていません。これは、JSF 2.0 と JSF 2.1 の両方に当てはまります。
ただし、今後の JSF 2.2 では、JSF 仕様の問題 996javax.faces.WEBAPP_RESOURCES_DIRECTORY
に従って、Web コンテンツ ルートからの相対パスをパラメーター値として取得する新しいコンテキスト パラメーターによってパスを変更できるようになります。
<context-param>
<param-name>javax.faces.WEBAPP_RESOURCES_DIRECTORY</param-name>
<param-value>WEB-INF/resources</param-value>
</context-param>
この例では、/resources
フォルダを に移動します。これにより/WEB-INF
、セキュリティが強化されます (つまり、 から独立してこれらのリソースにアクセスすることはできなくなりますFacesServlet
)。
特定のケースでは、JSF 2.2 にアップグレードしたときに次の設定を使用したいと考えています。
<context-param>
<param-name>javax.faces.WEBAPP_RESOURCES_DIRECTORY</param-name>
<param-value>assets</param-value>
</context-param>
これは、2.6.1.2 章で指定されている JAR リソースではなく、2.6.1.1 章で指定されている webapp 自体のリソースのみを対象とすることに注意してください。JAR リソースのパスはMETA-INF/resources
、JSF 仕様ではなく、サーブレット API 仕様によって制御されるため、そのままにしておく必要があります。ServletContext#getResource()
つまり、JSFの制御外にあるメソッドによって取得されたカバーの下にあります。