* Strutsインストールメモ [#lc984da1]
#html(<style>pre{font-size:14px;}</style>)
#html(<style>td{font-size:14px;}</style>)
◆Strutsのインストール~
・struts-1.2.7.tar.gzをダウンロード、展開して、lib以下のファイルを各ディレクトリに配置する。~
|ファイル|配置先ディレクトリ|h
|*.jar|/WEB-INF/lib|
|*.tld|/WEB-INF|
|validator-rules.xml|/WEB-INF|
◆Tomcatの設定ファイル(web.xml)にStruts用のアクションマッピングを設定~
・以下の記述によって *.do というリクエストは全て Struts(ActionServletクラス)に投げられるようになる。~
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
・
中略
・
<servlet>
<font color=red><b><servlet-name>action</servlet-name></b></font>
<font color=red><b><servlet-class>org.apache.struts.action.ActionServlet</servlet-class></b></font>
</servlet>
<servlet-mapping>
<font color=red><b><servlet-name>action</servlet-name></b></font>
<font color=red><b><url-pattern>*.do</url-pattern></b></font>
</servlet-mapping>
</web-app>
&br;
#html(<table><tr><td>◆Struts用タグライブラリを利用する為の設定<br/> ・/WEB-INF以下に配置したタグライブラリを利用する為に、/WEB-INF/web.xml を編集する。 </td></tr><tr><td>)
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
・
中略
・
<font color=red><b><jsp-config>
<font color=red><b>
<taglib>
<taglib-uri>/tags/struts-html</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/tags/struts-bean</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/tags/struts-tiles</taglib-uri>
<taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
</taglib>
</jsp-config></b></font>
</b></font>
</web-app>
#html(</td><td>)
・ここでタグライブラリのPathに別名をつけておく。~
・タグライブラリを利用するには各jspファイルのヘッダ部で、~
<%@ taglib prefix="html" uri="/WEB-INF/struts-html.tld" %>~
のように利用するタグの宣言が必要だが、~
左記のように宣言しておく事で、~
<%@ taglib prefix="html" uri="/tags/struts-html" %>~
と書けるようになる。~
※tldファイルで宣言しているURIはそのまま使用できる?~
#html(</td></tr></table>)