http://www.liyonghome.cn/index.php/archives/6.html
首先是準備工作吧,需要以下軟件,均可到官方網址下載
Struts2: http://apache.etoak.com/struts/binaries/struts-2.0.14-all.zip
Spring2.5: http://www.springsource.org/,下載spring-framework-2.5.zip(可選)
common-pool: http://www.apache.org/dist/commons/pool/commons-pool-current.zip
MyEclipse7: http://www.myeclipseide.com/
由于Myeclipse的最新版本7.0依然不支持struts2,所以我們需要手動去導入struts2相關jar文件和配置文件,之后使用Myeclipse自動再依次導入Spring2.5,Hibernate3.2。
一,建立一個新項目:
1.進入new project,選擇Web Project.
2.Project Name輸入”SSH2Demo”,另外選擇Java EE 5.0,之后點擊finish創建項目.
二,手工導入Struts2:
1.解壓struts-2.0.14-all.zip,找到lib文件夾.copy一下的jar文件到/WEB-INF/lib,當然這并一定是最精簡的,但是至少沒有問題. [xwork-2.0.7.jar, xml-apis-1.0.b2.jar, struts2-spring-plugin-2.0.14.jar, struts2-core-2.0.14.jar, oro-2.0.8.jar, ognl-2.6.11.jar, freemarker-2.3.8.jar, classworlds-1.1.jar, aopalliance-1.0.jar, antlr-2.7.2.jar以及commons-*.jar]
2.更新web.xml文件,加入
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
3.接著創建struts.xml,放到/WEB-INF/classes.
<?xml version=”1.0″ encoding=”UTF-8″ ?>
<!DOCTYPE struts PUBLIC
“-//Apache Software Foundation//DTD Struts Configuration 2.0//EN”
“http://struts.apache.org/dtds/struts-2.0.dtd“>
<struts>
<!– action內容 –>
</struts>
posted on 2009-02-18 23:43
donnie 閱讀(1148)
評論(0) 編輯 收藏 所屬分類:
java