How to include/import a JSP page inside a Facelets page?

匿名 (未验证) 提交于 2019-12-03 10:24:21

问题:

Does somebody know if it is possible to include/import a JSP page inside a Facelets page?

After several unsuccessful tries with <c:import>, <jsp:include>, <ui:include> and some research on internet I think it’s time to ask it in stackoverflow.

someJSFpage.xhtml:

<?xml version="1.0" encoding="ISO-8859-15" ?> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"     xmlns:h="http://java.sun.com/jsf/html"     xmlns:f="http://java.sun.com/jsf/core"     xmlns:ui="http://java.sun.com/jsf/facelets"     xmlns:c="http://java.sun.com/jsp/jstl/core">      <f:view contentType="text/html">          <h:head>             <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-15" />             <title>Home</title>         </h:head>          <h:body>              <xxxxx:import page="someJSPpage.jsp" />          </h:body>      </f:view> </html> 

回答1:

The OmniFaces project has a component <o:resourceInclude> for this.

The component can be used to catch the output from a JSP or Servlet resource and render it as output to the JSF writer. In effect, this allows you to include both Servlets and JSP pages in e.g. Facelets.

You can use it as follows:

<o:resourceInclude path="/someJSPpage.jsp" /> 

See the showcase with example here.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!