我正在製作一個使用模板化的簡單JSF應用程序這是非常基本的工作,但需要花費很多時間才能找到修復程序。 問題是,我有index.jsp,它只是將請求轉發到startPage.xhtml。 startPage.xhtml使用main.xhtml進行模板化。直到這裏一切都很好。但是有一個startPage.xhtml的錨鏈接,它將控制引導到expression/expression.html。當我點擊該鏈接時,瀏覽器不會呈現我的頁眉和頁腳(main.xhtml模板的一部分)。 IE考慮將表達式/ expression.xhtml文件打開並打開/保存對話框。JSF <ui:composition>在目標頁面上不工作
的index.jsp
<html>
<body>
<jsp:forward page="startPage.jsf" />
</body>
</html>
main.xhtml
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:c="http://java.sun.com/jstl/core">
<head>
<meta http-equiv="Content-Type" content="text/xhtml; charset=UTF-8" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<title>X</title>
<link
href="css/styles.css"
rel="stylesheet" type="text/css" />
<style>
.rich-table-headercell {
text-align: left;
}
.rich-table-cell {
vertical-align: top;
}
</style>
</head>
<body
style="bgcolor: #FFFFFF; margin-left: 0; margin-right: 0; margin-top: 0; margin-bottom: 20;">
<!-- Start Header -->
<h:form id="mainForm">
<ui:include src="../includes/header.xhtml"/>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td nowrap="nowrap">
<table style="background-repeat: no-repeat; background-color: #E9ECEF; " width="100%" height="20px">
<tr>
<td nowrap="nowrap"><img
src="images/spacer.gif"
width="18" height="1" border="0" alt="" />
</td>
<td class="globalNavGrey" align="right" nowrap="nowrap">
<h:outputText value="Help" /> <rich:spacer width="10" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</h:form>
<!-- main content area -->
<table align="left">
<tr>
<td><img
src="images/spacer.gif"
width="5" height="1" border="0" alt="" />
</td>
<td style="vertical-align: top;">
<!-- Body starts -->
<ui:insert name="body">
</ui:insert>
<!-- Body ends -->
</td>
</tr>
</table>
</body>
</html>
startPage.xhtml
<?xml version="1.0" encoding="windows-1252"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<ui:composition 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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/1999/xhtml http://www.w3.org/2002/08/xhtml/xhtml1-transitional.xsd"
template="/includes/main.xhtml">
<style>
.cellBackground {
background-color:yellow;
}
</style>
<ui:param name="subTitle" value="Understanding Disease Informatics System" />
<ui:define name="body">
<div
style="margin-left: 30px; top: 120px; width: 800px; margin-bottom: 50px;"
class="mainscreen">
<br/> <b><font size="+1" color="003366">
X </font> </b><br/> <br/> This page is the entry point for X
developers development is organized into these subsystems:
<p></p>
<center>
<table border="1" cellpadding="15" cellspacing="25">
<tr>
<td class="cellBackground" title="Enabled" >
<a href="${facesContext.externalContext.requestContextPath}/expression/expression.xhtml" style="font-size:20px;"> Expression Subsystem</a>
</td>
<td title="Disable" style="font-size:20px;" >Pathways</td>
</tr>
</table>
</center>
<hr></hr>
<font size="+1">
<a href="contact">Contacts</a>
<hr></hr>
</font>
</div>
</ui:define>
</ui:composition>
expression.xhtml
<?xml version="1.0" encoding="windows-1252"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/1999/xhtml http://www.w3.org/2002/08/xhtml/xhtml1-transitional.xsd">
<ui:composition template="main.xhtml">
<ui:param name="subTitle" value="Expression Data" />
<ui:define name="body">
Expression page!
</ui:define>
</ui:composition>
</html>
有什麼建議嗎?
注:因爲頁面上的所有鏈接都是靜態的,所以我沒有使用任何託管bean。
爲什麼當他們是模板的一部分時,您在expression.xhtml頁面中有html標記?您在startPage.xhtml中沒有他們 – GBa
我嘗試了不同的組合。最初我沒有標籤。比我雖然可能會解決,但..沒有工作。 – Rachel
您是否嘗試用替換錨標記? –
GBa