JSF2.2のプロジェクトを作成し、実行します。
【準備】
1.「Eclipse 4.3.0 Kepler(64ビット版)のインストール(解凍)方法」の手順で、Eclipseをインストール。
2.「サーバー・アダプターの追加方法(GlassFish)」の手順を実施。
3.「サーバー・ランタイムの設定(GlassFish4)」の手順を実施。
【手順1】
1.「Eclipse 4.3.0 Kepler(64ビット版)の起動方法」の手順で、Eclipseを起動。
2.メニューの「ファイル」⇒「新規」⇒「プロジェクト」を選択。
1.「Web」⇒「動的Webプロジェクト」を選択。
2.「次へ」ボタンをクリック。
1.「プロジェクト名」に「JSF22Sample001-HelloWorld」と入力。
2.ターゲット・ランタイムは「GlassFish 4.0」を選択。
3.構成の「変更」ボタンをクリック。
1.「JavaServer Faces」を選択。
2.「OK」ボタンをクリック。
1.「次へ」ボタンをクリック。
1.「次へ」ボタンをクリック。
1.「web.xmlデプロイメント記述子の生成」を選択。
2.「次へ」ボタンをクリック。
1.「完了」ボタンをクリック。
1.以下の様に、動的プロジェクトが作成されます。
【手順10】
1.「WebContent/WEB-INF/web.xml」を以下の様に入力。
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
id="WebApp_ID" version="3.1">
<display-name>JSF22Sample001-HelloWorld</display-name>
<welcome-file-list>
<welcome-file>faces/index.xhtml</welcome-file>
</welcome-file-list>
<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>/faces/*</url-pattern>
</servlet-mapping>
</web-app>
2.「Ctrl+Shift+F」を押し、ソースコードをフォーマッティング、「Ctrl+S」でファイルを保存。【手順11】
1.「faces-config.xml」を以下の様に入力。
<?xml version="1.0" encoding="UTF-8"?>
<faces-config xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd"
version="2.2">
</faces-config>
2.「Ctrl+Shift+F」を押し、ソースコードをフォーマッティング、「Ctrl+S」でファイルを保存。【手順12】
1.「任意のファイルの作成方法」の手順で、「WebContent/」ディレクトリに「index.xhtml」というファイルを作成。
2.「index.xhtml」を以下の様に入力。
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html">
<h:head>
</h:head>
<h:body>
<h:outputText value="ハローワールド JSF2.2"/>
</h:body>
</html>
3.「Ctrl+Shift+F」を押し、ソースコードをフォーマッティング、「Ctrl+S」でファイルを保存。以上です。









0 件のコメント:
コメントを投稿
注: コメントを投稿できるのは、このブログのメンバーだけです。