質問
この質問にはすでに答えがあります:
私のサーバーはGlassfish V3、私のブラウザはFirefox 3.6.3であり、NetBeans 6.8を使用しています。ラベルしか見てない。
<?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:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<title>Lookup</title>
</h:head>
<h:body>
<fieldset>
<legend>Enter Your Customer ID</legend>
<p>Legal ids are id001, id002, and id003.</p>
<f:view>
<h:form>
Customer ID:
<h:inputText value="#{bankForm.customerId}" />
<h:commandButton value="Show Current Balance"
action="#{bankForm.findBalance}" />
</h:form>
</f:view>
</fieldset>
</h:body>
</html>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" 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-app_3_0.xsd">
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>pages/customer-lookup</welcome-file>
</welcome-file-list>
</web-app>
解決
リクエスト URL (ブラウザのアドレス バーに入力したもの) が、 url-pattern
の FacesServlet
. 。つまり、ページを開かないでください http://example.com/context/page.xhtml, 、しかし、それを開く http://example.com/context/page.jsf. 。それ以外の場合は、 FacesServlet
は呼び出されず、JSF コンポーネントを含む XHTML ページはいかなる方法でも解析されません。次のような「プレーン HTML」タグのみが表示されます。 <fieldset>
などをブラウザで実行すると、返された HTML ソースに変更されていない JSF ソース コードが表示されます。 ソースを表示 ブラウザで。
他のヒント
これを web.xml に追加します。
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
あなたが直面している問題は次の方法で解決できるかもしれません web.xml に保存されているファイル WEB-INF Web アプリケーション プロジェクトの dir に追加します。ページを適切に実行するには、そのファイルを開いて次の XML コンテンツを追加する必要があります。
<web-app>
...
...
...
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
</web-app>
.xml ファイルが上記のディレクトリに存在しない場合は、Web アプリケーション プロジェクトをクリックしてファイルを追加し、新しいファイルを追加してから、Standard Deployment Descriptor (web.xml) を選択します。
このページで Faces-Servlet を設定したかどうかを確認してください