0

初めて JSF Facelet テンプレート/Facelet テンプレート クライアントを使用しようとしています。Netbeans 7.2.1 でテンプレートとテンプレート クライアントを作成しています。作成した JSF プロジェクトを実行して呼び出すhttp://localhost:8080/jpaweb/template.xhtmlと、テンプレート スタイルが表示されますが、クライアント テンプレートを呼び出すと、http://localhost:8080/jpaweb/client.xhtmlスタイルのないプレーン テキストが表示されます。両方のファイルは同じディレクトリにあり、Netbeans ウィザードによって作成されます。この問題で私を助けてください。

template.xhtml

<?xml version='1.0' encoding='UTF-8' ?> 
<!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:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html">

    <h:head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <link href="./resources/css/default.css" rel="stylesheet" type="text/css" />
        <link href="./resources/css/cssLayout.css" rel="stylesheet" type="text/css" />
        <title>Facelets Template</title>
    </h:head>

    <h:body>


        <div id="top" class="top">
            <ui:insert name="top">Top</ui:insert>
        </div>
        <div>
            <div id="left">
                <ui:insert name="left">Left</ui:insert>
            </div>
            <div id="content" class="left_content">
                <ui:insert name="content">Content</ui:insert>
            </div>
        </div>
    </h:body>

</html>

client.xhtml

<?xml version='1.0' encoding='UTF-8' ?>
<!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:ui="http://java.sun.com/jsf/facelets">

    <body>

        <ui:composition template="./template.xhtml">

            <ui:define name="top">
                Welcome, to my website
            </ui:define>

            <ui:define name="left">
                My links
            </ui:define>

            <ui:define name="content">
                This page is created for testing
            </ui:define>

        </ui:composition>

    </body>
</html>

Netbeans が JSF プロジェクトを作成している場合、JSF テンプレートとテンプレート クライアントはこの結果を取得します。Netbeans 1.7.0 でも試しました。同じ問題。

編集:私は好きではなく、うまくhttp://localhost:8080/jpaweb/client.xhtmlいったようにページを実行しますhttp://localhost:8080/jpaweb/faces/client.xhtml。私のプロジェクトには「faces」ディレクトリはありません。すべての JSF リンクに「顔」を追加する必要がありますか?

編集 2: netbeans は、プロジェクトにそのようなディレクトリがなくても、すべての jsf ファイルが faces ディレクトリに保持されるように自動構成すると思います。また、プロジェクト プロパティ -> フレームワーク -> JavaServer Faces -> 構成には、値が割り当てられた /faces/* を持つフィールド JSF サーブレット URL パターンがあります。それは、faces ディレクトリにあるかのように jsf ファイルを呼び出さなければならないことを意味すると思います。私のプロジェクトに表示されるように強制しようとするのは間違いでした:)

4

2 に答える 2

1

解決しました。の値をProject properties -> Frameworks -> JavaServer Faces -> Configuration -> JSF Servlet URL Patternから/faces/*に変更したところ*.xhtml、問題なく動作しました。

于 2013-03-02T18:51:45.157 に答える