請下載 struts-2.2.x.x-all.zip 檔案,一般來說是解壓縮後直接使用 lib/ 內的,不過實際上卻缺少 javassist-3.7.ga.jar 檔案,可以在 apps/struts2-blank.war 範例檔的 WEB-INF/lib/ 內找就有了。
所以最快速讓專案加入 struts 2.2 的框架就可以只拷貝 struts2-blank.war 解壓縮後在 WEB-INF/lib/ 下的所有 JAR 檔案,放到 Eclipse 專案下的 WebContent/WEB-INF/lib/ 目錄。
然後修改 WebContent/WEB-INF/web.xml 增加:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>struts2211demo</display-name>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
最後在 src/ 增加 struts.xml 設定就可以開始探索了。