jsf - 用户界面 :include can not include pages with different server context

标签 jsf include

在我的 tomcat 中,我定义了两个上下文。

其中一个是我的应用程序 URL,即

http://localhost:8080/mysite/faces/abc.xhtml

另一个用于放置我所有可能被其他应用程序使用的静态文件。

http://localhost:8080/files/myfile.html

例如,在我的应用程序 .xhtml 文件中,我想包含来自其他上下文的页面

<ui:include src="/files/myfile.html">

但我总是收到错误

javax.faces.view.facelets.TagAttributeException:.....Invalid path : /files/myfile.html

看起来 ui:include 不适合在这里使用,因为它只查找上下文相关的路径。那我应该用什么?

最佳答案

有几个选项:

  1. 使用<iframe>相反。

  2. 将共享文件重构为一个单独的 Web 片段项目,该项目最终应作为 JAR 出现在 /WEB-INF/lib 中。两个网络应用程序的。将 Facelets 资源放入/META-INF/resources单独的 Web 片段项目的文件夹。它将适用于 <ui:include>通常的方式:Structure for multiple JSF projects with shared code .

  3. 在 JSF 1.x 上时,使用自定义 com.sun.facelets.impl.DefaultResourceResolver : How to use Facelets composition with files from another context .

  4. 在 JSF 2.x 上时,使用自定义 javax.faces.view.facelets.ResourceResolver : how to share a jsf error page between multiple wars .

  5. 在 JSF 2.2+ 上时,使用自定义 javax.faces.application.ResourceHandler : Obtaining Facelets templates/files from an external filesystem or database .

关于jsf - 用户界面 :include can not include pages with different server context,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11965157/

相关文章:

java - 为 JSF/ICEfaces 设置浮点格式化语言环境?

java - 如何从渲染的 h :outputText? 将参数传递给方法

jquery - 如何在 NetBeans IDE 中实现 Jquery UI Themeroller

java - 多列的 PrimeFaces DataExporter 到 XLS 无法正常工作

css - JSF 菜单未格式化 STLyed

jsp - Struts2:如何从 <jsp:include> 读取参数

jsf - 使用 <f :convertDateTime> with <h:commandLink>

c++ - 此处首先定义的多重定义 gcc

c++ - 尝试构建非常简单的 gtkmm 应用程序时出现编译器错误 :

android - 覆盖android :id attribute with <include> doesn't work