Struts/Tilesの基礎
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
単語検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
#topicpath
----
#contents
**Tilesとは [#pb14829b]
Tilesとは、JSPでいうInclude機能を強化したフレームワークで...
**とりあえず練習っつうことで [#w39ebeea]
***ファイル構成 [#y3c1b657]
とりあえずやってみましょう。サンプルのアプリを作ってみま...
ファイル構成は以下のようになりました。
#ref(ファイル構成.png)
~
-/WEB-INF/struts-config.xml <-tilesの設定ファイルの名前と...
-/WEB-INF/tiles-defs.xml
-/layoutBase.jsp
-/menubar.jsp
-/body.jsp
-/index.jsp <- 最終的に呼び出すファイル
#ref(image.png)
***それぞれの内容 [#l585ad42]
struts-config.xmlは以下を追加しました。
<plug-in className="org.apache.struts.tiles.TilesPlugin">
<set-property property="moduleAware" value="false" />
<set-property property="definitions-debug" value="0" />
<set-property property="definitions-parser-details" val...
<set-property property="definitions-parser-validate" va...
<set-property property="definitions-config" value="/WEB...
↑Tilesの設定ファイルの場所
</plug-in>
tiles-defs.xmlは以下のようになりました。
<tiles-definitions>
<definition name="layoutBase" path="/layoutBase.jsp">
↑pathで指定したJSPファイルを、nameで指定した名称でinclu...
<put name="menubar" value="/menubar.jsp" />
↑上のJSP(layoutBase.jsp) 内で、呼び出すJSPの指定。
<put name="body" value="/body.jsp" />
↑上のJSP(layoutBase.jsp) 内で、呼び出すJSPの指定。
</definition>
</tiles-definitions>
layoutBase.jsp は以下の記述をしました。
<table border="0" style="width: 100%">
<tr>
<%-- メニューの記述 --%>
<td id="menubar"><tiles:insert attribute="menubar" /></...
↑putタグはattribute属性で呼び出す
<%-- ボディの記述 --%>
<td id="body"><tiles:insert attribute="body" /></td>
↑putタグはattribute属性で呼び出す
</tr>
</table>
index.jsp は以下の記述をしました。((insertのdefinition属...
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles...
<tiles:insert definition="layoutBase" flush="true"/>
↑definitionタグはdefinition属性で呼び...
***追加作業 [#a33081db]
今回はindex.jspで
<tiles:insert definition="layoutBase" flush="true"/>
として、struts-config.xmlでindex.jspに遷移させるというや...
<action name="hoge" path="/foo" scope="request" type="ki...
<!-- <forward name="success" path="/index.jsp"></forwa...
<forward name="success" path="layoutBase"></forward> <...
</action>
って書くことができます。こうすることによって、確かに保守...
***感想 [#qafe8535]
とりあえずいろいろ試行錯誤しましたが、上の内容で稼動しま...
引き続き[[Struts/TilesのTIPS集]]へ
----
この記事は
#vote(おもしろかった[241],そうでもない[40])
#comment
#topicpath
SIZE(10){現在のアクセス:&counter;}
終了行:
#topicpath
----
#contents
**Tilesとは [#pb14829b]
Tilesとは、JSPでいうInclude機能を強化したフレームワークで...
**とりあえず練習っつうことで [#w39ebeea]
***ファイル構成 [#y3c1b657]
とりあえずやってみましょう。サンプルのアプリを作ってみま...
ファイル構成は以下のようになりました。
#ref(ファイル構成.png)
~
-/WEB-INF/struts-config.xml <-tilesの設定ファイルの名前と...
-/WEB-INF/tiles-defs.xml
-/layoutBase.jsp
-/menubar.jsp
-/body.jsp
-/index.jsp <- 最終的に呼び出すファイル
#ref(image.png)
***それぞれの内容 [#l585ad42]
struts-config.xmlは以下を追加しました。
<plug-in className="org.apache.struts.tiles.TilesPlugin">
<set-property property="moduleAware" value="false" />
<set-property property="definitions-debug" value="0" />
<set-property property="definitions-parser-details" val...
<set-property property="definitions-parser-validate" va...
<set-property property="definitions-config" value="/WEB...
↑Tilesの設定ファイルの場所
</plug-in>
tiles-defs.xmlは以下のようになりました。
<tiles-definitions>
<definition name="layoutBase" path="/layoutBase.jsp">
↑pathで指定したJSPファイルを、nameで指定した名称でinclu...
<put name="menubar" value="/menubar.jsp" />
↑上のJSP(layoutBase.jsp) 内で、呼び出すJSPの指定。
<put name="body" value="/body.jsp" />
↑上のJSP(layoutBase.jsp) 内で、呼び出すJSPの指定。
</definition>
</tiles-definitions>
layoutBase.jsp は以下の記述をしました。
<table border="0" style="width: 100%">
<tr>
<%-- メニューの記述 --%>
<td id="menubar"><tiles:insert attribute="menubar" /></...
↑putタグはattribute属性で呼び出す
<%-- ボディの記述 --%>
<td id="body"><tiles:insert attribute="body" /></td>
↑putタグはattribute属性で呼び出す
</tr>
</table>
index.jsp は以下の記述をしました。((insertのdefinition属...
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles...
<tiles:insert definition="layoutBase" flush="true"/>
↑definitionタグはdefinition属性で呼び...
***追加作業 [#a33081db]
今回はindex.jspで
<tiles:insert definition="layoutBase" flush="true"/>
として、struts-config.xmlでindex.jspに遷移させるというや...
<action name="hoge" path="/foo" scope="request" type="ki...
<!-- <forward name="success" path="/index.jsp"></forwa...
<forward name="success" path="layoutBase"></forward> <...
</action>
って書くことができます。こうすることによって、確かに保守...
***感想 [#qafe8535]
とりあえずいろいろ試行錯誤しましたが、上の内容で稼動しま...
引き続き[[Struts/TilesのTIPS集]]へ
----
この記事は
#vote(おもしろかった[241],そうでもない[40])
#comment
#topicpath
SIZE(10){現在のアクセス:&counter;}
ページ名: