struts 1項目を設定します
1.IDE(Eclipseなど)を開いて、新しいWeb Project(EclipseではDynamic Web Project)を作成します。
2.次のjarカバンをWebConteent/WEB-INF/libディレクトリに置いてください。セキュリティのため、tomcatはデフォルトでこのディレクトリからプロジェクトのjarリソースをロードします。
ANtlr.jar
commons-beanutils.jar
common-digester.jar
commons-filep load.jar
commons-loging.jar
commons-validator.jar
jakata-オロロ.jar
jstl.jar
standard.jar
struts.jar
3.struts 1はservletで起動されるので、web.xmlに次の内容を加える:
4.WebContent/WEB-INFディレクトリでstruts-config.xmlを作成する:
6.新しいアクションを作成する:
8.ブラウザ入力http://localhost:8080/encryption/list.doを選択します。正確にlist.jspページにジャンプしますか?
2.次のjarカバンをWebConteent/WEB-INF/libディレクトリに置いてください。セキュリティのため、tomcatはデフォルトでこのディレクトリからプロジェクトのjarリソースをロードします。
ANtlr.jar
commons-beanutils.jar
common-digester.jar
commons-filep load.jar
commons-loging.jar
commons-validator.jar
jakata-オロロ.jar
jstl.jar
standard.jar
struts.jar
3.struts 1はservletで起動されるので、web.xmlに次の内容を加える:
<servlet>
<servlet-name>struts</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>2</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>struts</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>struts</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
WebContentディレクトリの下でindex.jspを作成して、後のテストを便利にします。4.WebContent/WEB-INFディレクトリでstruts-config.xmlを作成する:
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
<struts-config>
<form-beans />
<global-forwards />
<action-mappings />
</struts-config>
5.web serverで動作し、コンソールが正常に起動しているかどうかを確認し、ブラウザを開いてアクセスするhttp://localhost:8080/encryption (ポート番号はweb serverに配置されています)。6.新しいアクションを作成する:
package com.john.encryption.web.struts.action;
public class ListAction extends Action {
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
return mapping.findForward("success");
}
}
7.struts-config.xmlにactionを加える構成:
<action-mappings>
<action path="/list" type="com.john.encryption.web.struts.action.ListAction">
<forward name="success" path="/WEB-INF/pages/cipher/list.jsp"></forward>
</action>
</action-mappings>
WEB-INF/pages/cipherの下にlist.jspを新規作成します。8.ブラウザ入力http://localhost:8080/encryption/list.doを選択します。正確にlist.jspページにジャンプしますか?