<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:body>
<title><ui:define name="title">Page 2</ui:define></title>
<ui:composition template="template/common/commonLayout.xhtml">
<ui:define name="content">
This is the content of Page 2 page<br/>
<h:form prependId="false">
<h:commandButton id="goToIndex" value="Go to Index" action="index" />
</h:form>
<a href="index.xhtml">Index</a>
</ui:define>
</ui:composition>
</h:body>
</html>
我有兩個相同的facelets頁面:index.xhtml和page2.xhtml,它們相互鏈接。我也有一個模板文件。除了標題,內容文本和命令按鈕值中的頁面名稱之外,索引和page2之間的代碼沒有區別。<a href>鏈接導航不檢測JSF 2.0中的模板Facelets頁面
當我點擊由表單實現的goToIndex按鈕導航到index.xhtml時,一切都按預期工作:它會轉到index.xhtml。但是,當我點擊[a href]鏈接實現的鏈接導航到index.xhtml時,它會轉到index.xhtml,但似乎忽略了頁面的所有模板設置,包括任何表單標記。呈現的唯一內容是限制在「content」定義中的文本,但沒有任何css格式。
這件事發生在雙方。 「index - > page2」和「pag2 - > index」
任何想法爲什麼會出現這種情況?
謝謝,馬特。它像一個魅力。 –