Struts Tiles

「Struts Tiles」の編集履歴(バックアップ)一覧はこちら

Struts Tiles」(2006/03/22 (水) 03:07:19) の最新版変更点

追加された行は緑色になります。

削除された行は赤色になります。

* 設定 'maven genapp', type = web でプロジェクトを作成 build.properties.jboss maven.xml project.properties project.xml src src/conf src/conf/app.properties src/conf/cactus-web.xml src/java src/java/yt src/java/yt/tiles src/java/yt/tiles/HelloWorldServlet.java src/test src/test/yt src/test/yt/tiles src/test/yt/tiles/SanityTest.java src/test-cactus src/test-cactus/yt src/test-cactus/yt/tiles src/test-cactus/yt/tiles/HelloWorldServletTest.java src/test-cactus/yt/tiles/HttpUnitTest.java src/webapp src/webapp/sample.jsp tld をおくとするとおそらく src/conf 以下なので struts 関連の tld をそこに配置。 bash-3.00$ find src/conf src/conf src/conf/app.properties src/conf/cactus-web.xml src/conf/tld src/conf/tld/struts-bean.tld src/conf/tld/struts-html.tld src/conf/tld/struts-logic.tld src/conf/tld/struts-nested.tld src/conf/tld/struts-tiles.tld web.xml には tiles に関する記述が必要なのだが、web タイプの project では web.xml は XDoclet が生成するため直接記述できない。 <taglib> <taglib-uri>/WEB-INF/struts-tiles.tld</taglib-uri> <taglib-location>/WEB-INF/struts-tiles.tld</taglib-location> </taglib> 一回 'maven war' を実行してみる。 bash-3.00$ find . -name web.xml ./target/xdoclet/webdoclet/WEB-INF/web.xml tablib に関する記述はないが、次の様なコメントが web.xml にある。 <!-- To add taglibs by xml, create a file called taglibs.xml and place it in your merge dir. --> project.properties に次の行がある。 maven.xdoclet.webdoclet.deploymentdescriptor.0.mergeDir=src/merge bash-3.00$ mkdir src/merge bash-3.00$ cat >src/merge/taglibs.xml <taglib> <taglib-uri>/WEB-INF/struts-tiles.tld</taglib-uri> <taglib-location>/WEB-INF/struts-tiles.tld</taglib-location> </taglib> 'maven war' を実行 target/xdoclet/webdoclet/WEB-INF/web.xml web.xml に taglibs.xml が含まれるようになった bash-3.00$ jar tf target/tilestest.war META-INF/ META-INF/MANIFEST.MF WEB-INF/ WEB-INF/classes/ WEB-INF/classes/yt/ WEB-INF/classes/yt/tiles/ WEB-INF/lib/ WEB-INF/tld/ WEB-INF/tlds/ sample.jsp WEB-INF/classes/app.properties WEB-INF/classes/yt/tiles/HelloWorldServlet.class WEB-INF/lib/commons-logging-1.0.3.jar WEB-INF/tlds/taglib.tld WEB-INF/web.xml しかし、war には tld が含まれていない。 war plugin の manual によると tld のコピー先は maven.war.tld.dir できまり WEB-INF/tld. Subdirectory of web application context root directory where tag library descriptors (tld files) will be copied. The Maven WAR Plugin copies to this location all dependencies, specified in the POM, of the type tld and marked with a property of war.bundle set to true. See the section below for more information. 具体的には次の様な記述が必要 <dependency> <artifactId>struts-logic</artifactId> <groupId>struts</groupId> <version>1.1</version> <type>tld</type> <properties> <war.bundle>true</war.bundle> </properties> </dependency> http://maven.ozacc.com/ を使って struts-tiles tld の情報を検索 1.1 が ibiblio にあることを確認 web.xml に次の dependency を追加 <dependency> <artifactId>struts-tiles</artifactId> <groupId>struts</groupId> <version>1.1</version> <type>tld</type> <properties> <war.bundle>true</war.bundle> </properties> </dependency> war ファイルに structs-tiles-1.1.tld が含まれるようになった。 taglibs.xml をバージョンを含む名前に変更。 src/webapp/classicLayout.jsp を作成 bash-3.00$ cat >src/webapp/classicLayout.jsp <%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %> <%-- Layout component parameters : title, header, menu, body, footer --%> <HTML> <HEAD> <title><tiles:getAsString name="title"/></title> </HEAD> <body bgcolor="#ffffff" text="#000000" link="#023264" alink="#023264" vlink="#023264"> <table border="0" width="100%" cellspacing="5"> <tr> <td colspan="2"><tiles:insert attribute="header" /></td> </tr> <tr> <td width="140" valign="top"> <tiles:insert attribute='menu'/> </td> <td valign="top" align="left"> <tiles:insert attribute='body' /> </td> </tr> <tr> <td colspan="2"> <hr> </td> </tr> <tr> <td colspan="2"> <tiles:insert attribute="footer" /> </td> </tr> </table> </body> </html> index.jsp を作成 bash-3.00$ cat >src/webapp/index.jsp <%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %> <tiles:insert page="./classicLayout.jsp" flush="true"> <tiles:put name="title" value="Page Title" /> <tiles:put name="header" value="./header.jsp" /> <tiles:put name="footer" value="./footer.jsp" /> <tiles:put name="menu" value="./menu.jsp" /> <tiles:put name="body" value="./main.jsp" /> </tiles:insert> bash-3.00$ cd src/webapp/ bash-3.00$ cat >header.jsp <html><h2>this is header</h2></html> bash-3.00$ cat >footer.jsp <html><body><h3>this is footer</h3></body></html> bash-3.00$ cat >menu.jsp <html><body>this is menu</body></html> bash-3.00$ cat >main.jsp <html><body>This is main</body></html> deploy してアクセスすると次のエラーがでる。 org.apache.jasper.JasperException: File "/WEB-INF/struts-tiles.tld" not found web.xml がおかしいかと思ったが問題は classicLayout.jsp と index.jsp の tld の指定らしい。 実行時にえらーとなる。そういえば struts.jar を含めていなかった。 <dependency> <id>struts</id> <version>1.2.8</version> <properties> <war.bundle>true</war.bundle> </properties> </dependency> また、クラスタリングに関するメッセージが出ていたのでつぎの 行を project.properties に追加 maven.xdoclet.webdoclet.deploymentdescriptor.0.distributable=false rebuild, deploy 実行で、動作することを確認

表示オプション

横に並べて表示:
変化行の前後のみ表示:
ツールボックス

下から選んでください:

新しいページを作成する
ヘルプ / FAQ もご覧ください。