问题
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.
来源:https://stackoverflow.com/questions/10835594/how-to-include-import-a-jsp-page-inside-a-facelets-page