用戶工具

網站工具


struts

這是本文件的舊版!


Struts

在 Eclipse 使用 Struts 1.3.x

建立支援 Struts 的專案環境

1. Eclipse 中建立一個 Dynamic Web Project 然後

2. 將 Struts 的 lib 下的檔案都複製到 WebContent/WEB-INF/lib 目錄下

3. 將 Struts 的 src\taglib\src\main\resources\META-INF\tld 下的 *.tld 複製到 WebContent/WEB-INF/lib

4. 在 WebContent/WEB-INF 目錄下建立 struts-config.xml 內容如下:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" 
"http://struts.apache.org/dtds/struts-config_1_2.dtd">  
<struts-config> 
  <data-sources />
  <form-beans />
  <global-exceptions />
  <global-forwards />
  <action-mappings />
  <message-resources parameter="struts.ApplicationResources" />
</struts-config>

5. 修改 WebContent/WEB-INF/web.xml 增加處理 Struts 動作的 ActionServlet 的設定,內容下:

<servlet>
  <servlet-name>action</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>3</param-value>
  </init-param>
  <init-param>
    <param-name>detail</param-name>
    <param-value>3</param-value>
  </init-param>
  <load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
  <servlet-name>action</servlet-name>
  <url-pattern>*.do</url-pattern>
</servlet-mapping>

建立首頁(index.jsp)

待續…

struts.1234404272.txt.gz · 上一次變更: 2010/08/23 15:30 (外部編輯)