Struts 2.X of Eclipse for J2EE – 安裝

Struts 在 Eclipse 中設置方法的教學在網路上很多;信手拈來就是一堆,自己寫一個當做是記錄、也是檢視自己是否透撤瞭解的一個方法。

File -> New -> Dynamic Web Project
Generate web.xml dployment descriptor 記得要選取打勾

依照 Maven 初探 這篇、讓這個專案成為 Maven Project(或是直接建立也可、另篇再提)。

在 Maven 資源庫中查到 Struts 所需版本的資料、將其填入。

  • groupId : org.apache.struts
  • aftifactId : struts2-core
  • version : 2.5.14.1

或者直接在 pom.xml 寫入以下資料 :

<dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-core</artifactId>
    <version>2.5.14.1</version>
</dependency>

稍等一下就可以看到匯入的 Struts jars 了。

先看一下一個最初階的 Struts 程式完成後的主要檔案位置、下一篇再來講裡面的內容吧:

  • src\struts.xml
  • src\com.test.conntroller.hello.java
  • WebContent\WEB-INF\web.xml
  • WebContent\hello.jsp

發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *