我剛剛創建了一個新的IceFaces應用程序,並試圖在所有頁面中包含一個導航欄。當我使用jsp:directive.include
標籤時,包含該文件,但是當我使用jsp:include
時,它似乎未加載。事實上,當我在瀏覽器中檢查HTML源代碼時,就像包含的文件完全是空的。我不想使用jsp:directive.include
,因爲它不會自動顯示包含文件的任何更新。JSP:include沒有渲染包含的文件
我的環境:Eclipse 3.5,Tomcat 6,JSF 1.2,IceFaces 1.8。
步驟來重現問題的代碼段:
創建一個新的動態Web項目具有以下選項: 目標運行時:的Apache Tomcat V6.0 動態Web模塊版本:2.5 配置:ICEfaces項目
創建一個新的ICEFaces JSPX文件 - 主文件。有些代碼:
<jsp:directive.page contentType="text/html;charset=ISO-8859-1" /> <f:view > <ice:outputDeclaration doctypeRoot="HTML" doctypePublic="-//W3C//DTD HTML 4.01 Transitional//EN" doctypeSystem="http://www.w3.org/TR/html4/loose.dtd" /> <html> <head> <title>test file</title> <link rel="stylesheet" type="text/css" href="./xmlhttp/css/rime/rime.css" /> </head> <body> <jsp:directive.include file="./vertical_navigation.jsp" /> <!-- working --> <jsp:include page="./vertical_navigation.jsp" /> <!-- not working, no error though --> </body> </html> </f:view>
創建該文件被收錄,也可作爲一個新的ICEFaces的JSPX文件。簡化代碼:
<ice:form> <ice:panelGrid columns="1" width="152"> <ice:graphicImage url="./img/image.jpg"></ice:graphicImage> <ice:panelCollapsible expanded="true"> <f:facet name="header"> <ice:panelGroup> <ice:outputText value="Customer"/> </ice:panelGroup> </f:facet> <ice:panelGrid columns="1"> <ice:commandLink action="customer"><ice:outputText value="Customer name" /></ice:commandLink> </ice:panelGrid> </ice:panelCollapsible> </ice:panelGrid> </ice:form> </body> </html> </f:view>
一些言論:
- 我對JSF完全陌生,所以請原諒我的任何明顯的錯誤。
- 在主文件(第一個)我沒有同時使用兩個標籤。我在這裏貼了兩個,只是爲了表明我正在嘗試兩種選擇。
- 我將這兩個文件創建爲「ICEFaces JSPX文件」,但第二個文件分配了.jsp擴展名。
- 當我使用
directive.include
標記時,將加載包含的文件。但如果我改變它,它不會自動重新發布。
的原因目前尚不清楚,但我發現了一些文件指出,我們不應該用jsp:包括ICEfaces的:HTTP://www.icefaces。 org/docs/v1_8_2/htmlguide/devguide/references2.html – 2010-10-08 03:11:02
因爲他們強烈鼓勵XML標記。順便說一下,你看過[Facelets](http://facestutorials.icefaces.org/tutorial/facelets-tutorial.html)嗎?這大概是JSPX的擴展,也是Java EE 6繼承JSP的原因。有一個''。 –
BalusC
2010-10-08 10:57:04
是的,我正在嘗試使用Facelets,但我有點困惑。無論如何,我不再使用jsp:include。 jsp:directive.include正常工作,刷新任何已更改的文件並不重要。 – 2010-10-11 03:12:48