我的模板的结构
布局.xhtml
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
...
<h:form id="headerForm" />
...
<ui:insert name="content">Put default content here, if any.</ui:insert>
...
集成.xhtml
<ui:composition template="/WEB-INF/templates/layout.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:c="http://java.sun.com/jstl/core">
<ui:define name="content">
...
<ui:insert name="tabContent">Tab content</ui:insert>
...
</ui:define>
customerSide.xhtml
<ui:composition template="/pages/protected/integration/integration.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<ui:define name="tabContent">
...
</ui:define>
</ui:composition>
当我转到该页面时,http://localhost:8080/dcc/pages/protected/integration/customerSide.xhtml
我得到了这个异常
java.lang.IllegalStateException: Component ID headerForm has already been found in the view.
headerForm 没有问题。如果我删除它,它将在具有 id 的下一个组件上失败。如何嵌套这些模板而不会出现错误?