2011-08-17 2 views
2

저는 템플릿 사용을 사용하는 간단한 JSF 응용 프로그램을 만들고 있습니다. 매우 기본적인 것이지만 수정을 찾는 데는 많은 시간이 걸립니다. 문제는 startPage.xhtml로 요청을 전달하는 index.jsp입니다. startPage.xhtml은 템플릿 작성에 main.xhtml을 사용합니다. 여기까지 모든 것이 괜찮습니다. 그러나 컨트롤을 expression/expression.html로 유도하는 startPage.xhtml의 앵커 링크가 있습니다. 링크를 클릭하면 브라우저가 내 머리글과 바닥 글 (main.xhtml 템플릿의 일부)을 렌더링하지 않습니다. IE는 expression/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> 
,

제안 사항이 있으십니까?

참고 : 페이지의 모든 링크는 정적이므로 관리 빈을 사용하지 않습니다. 귀하의 index.jsp

+0

왜 템플릿에 포함되어있을 때 expression.xhtml 페이지에 html 태그가 있습니까? startPage.xhtml에 있지 않았습니다. – GBa

+0

다른 조합을 시도했습니다. 처음에는 태그가 없었습니다. 나는 그것이 해결 될지도 모르지만, .. 작동하지 않았다. – Rachel

+0

앵커 태그를 으로 바꾸어 보았습니까? – GBa

답변

2
<jsp:forward page="startPage.jsf" /> 

FacesServlet*.jsf<url-pattern>에 매핑 web.xml에 있음을 시사한다.

그러나

,

<a href="${facesContext.externalContext.requestContextPath}/expression/expression.xhtml" style="font-size:20px;"> Expression Subsystem</a> 

당신의 startPage.xhtmlexpression.xhtml 대신 expression.jsf에 대한 링크가 있습니다. IE는 생성 된 HTML 대신 원시 및 분석되지 않은 JSF 소스 코드를 검색합니다. IE가 application/xhtml+xml 파일을 가져올 때마다 파일을 어떻게 처리할지 모르기 때문에 다운로드하라는 메시지가 표시됩니다.

FacesServlet 인 링크를 web.xml에 수정해야합니다.

<a href="#{request.contextPath}/expression/expression.jsf" style="font-size:20px;"> Expression Subsystem</a> 

당신은 또한 단지 *.xhtmlFacesServlet<url-pattern>을 변경할 수

또는 (나 또한 상황에 맞는 경로 검색을 단순화 참고). 이렇게하면 추한 index.jsp을 모두 없애고 <welcome-file>startPage.xhtml으로 설정하고 항상 .xhtml으로 끝나는 URL/링크를 사용할 수 있습니다.

+0

문제로 의심 스럽지만 시도했을 때 .jfs 형식을 만들었고 작동하지 않았습니다. 그런 다음 질문을 게시했습니다. 그래, 고마워. 확실히 내 idex.jsp를 없애기 위해 web.xml을 바꿀 예정이다. – Rachel

+0

. 천만에. – BalusC

관련 문제