问题描述
在我的tomcat中,我定义了两个上下文。
In my tomcat I have defined two context.
一个是我的应用程序URL,
One is my application URL, which is
http:// localhost:8080 / mysite / faces / abc.xhtml
另一个用于放置所有我的静态文件可能被其他应用程序使用。
another one is used to put all my static files which maybe used by other applications.
http:// localhost:8080 / files / myfile.html
在我的应用程序.xhtml文件中,我想要包含来自其他上下文的页面,例如
In my application .xhtml file I want to include page from the other context, for example
< ui:include src =/ files / myfile.html>
但我总是收到错误
javax.faces.view.facelets.TagAttributeException:.....路径无效:/files/myfile.html
看起来ui:include不适合在这里使用,因为它只查找与上下文相关的路径。我应该使用什么?
It looks like ui:include is not appropriate to be used here because it only looks for context related path. What should I use then?
推荐答案
有几种选择:
-
改为使用
< iframe>
。
重构将共享文件放入一个单独的Web片段项目中,该项目最终应该是两个webapps的 / WEB-INF / lib
中的JAR。将Facelets资源放在单独的Web片段项目的 / META-INF / resources
文件夹中。它将以< ui:include>
的常用方式提供:。
Refactor the shared files into a separate web fragment project which should end up as JAR in /WEB-INF/lib
of both webapps. Put the Facelets resources in the /META-INF/resources
folder of the separate web fragment project. It'll be available for <ui:include>
the usual way: Structure for multiple JSF projects with shared code.
在JSF 1.x上时,使用自定义 com.sun.facelets.impl.DefaultResourceResolver
:。
When on JSF 1.x, use a custom com.sun.facelets.impl.DefaultResourceResolver
: How to use Facelets composition with files from another context.
启用时JSF 2.x,使用自定义 javax.faces.view.facelets.ResourceResolver
:。
When on JSF 2.x, use a custom javax.faces.view.facelets.ResourceResolver
: how to share a jsf error page between multiple wars.
在使用JSF 2.2+时,使用自定义 javax.faces.application.ResourceHandler
:。
When on JSF 2.2+, use a custom javax.faces.application.ResourceHandler
: Obtaining Facelets templates/files from an external filesystem or database.
这篇关于ui:include不能包含具有不同服务器上下文的页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!