图像不会显示,导航不会发生(学习?JSF 2)

时间:2013-11-24 22:11:11

标签: jsf-2

这是尝试显示和导航的JSF代码。

<!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">
<h:head>
  <title>A Simple JavaServer Faces 2.0 View</title>
</h:head>
<h:body>
  <h:form>
      <h1>Images</h1>
 <p><h:graphicImage library = "/images" name = "img_jsf.jpg"/> 
    <h:button value = "Proceed to page 2" outcomr = "gotopage2"/></p>

     <p>Above the Main table</p>

      <h:dataTable border="1" var="book"
                   value="#{catalogBean.bookList}">

          <h:column>
              <h:graphicImage url="#{book.imageLink}" height = "150" width= "150"/> 
              <h:link outcome="gotopage2">
              <h:outputText value = "Proceed to page 2"/>
              </h:link>

          </h:column>

      </h:dataTable>

       </h:form>

这是faces-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<faces-config
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
    version="2.0"
>
    <!-- Comments here, wow talk about hard to do this right.... -->


   <navigation-rule>
   <from-view-id>CatProdPage.xhtml</from-view-id>
    <navigation-case>
     <from-outcome>gotopage2</from-outcome>
     <to-view-id>/storePage2.xhtml</to-view-id>
   </navigation-case>
  </navigation-rule>
</faces-config>

这是storePage2.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">
<h:head>
  <title>Store Page2</title>
</h:head>
    <ui:composition template="./../template/secondaryTemplate.xhtml">
        <ui:define name="header">
            <ui:include src="/common/header.xhtml" />
        </ui:define>
        <ui:define name="leftMenu">
            <ui:include src="/common/leftMenu.xhtml" />
        </ui:define>
        <ui:define name="CatProdPage">
            <ui:include src="CatProdPage.xhtml" />
        </ui:define>
        <ui:define name="page2">
            <ui:include src="page2.xhtml" />
        </ui:define>
    </ui:composition>
</html>

这是页面上“查看来源”代码段的结果

      <h1>Images</h1>
 <p><img src="RES_NOT_FOUND" /><input type="button" onclick="window.location.href='/jsfreg/faces/store/storePage.xhtml'; return false;" value="Proceed to page 2" /></p>

     <p>Above the Main table</p><table border="1">
<tbody>
<tr>
<td><img src="/jsfreg/resources/images/img_coreJsf.jpg" height="150" width="150" /><span>: This link is disabled because a navigation case could not be matched.Proceed to page 2</span></td>
</tr>

核心问题是我无法显示图像,无法使静态导航工作。 我已经尝试将images / * .jpg文件夹移动到我可以想到的应用程序根目录下的每个可能位置,在WEB-INF下等。 我正在使用Glassfish 4和Maven。

0 个答案:

没有答案