1001_____struts_____手動配置

文章只是做一個記錄,以便日後查閱
本人技術有限,有誤的地方請友善指出,謝謝,O(∩_∩)O~


工具:myeclipse8.5
數據庫:mysql
使用框架:struts2.3 + hibernate3 + spring3.0 + junit4


1,新建一個web項目,其他的就不多說了
2,新建一個user libraries ,此處取名struts,導入需要的基礎包
[img]http://dl.iteye.com/upload/picture/pic/129059/5fe787e5-d3ce-3968-b0f1-5f9ddf31f546.jpg[/img]
3,配置web.xml
<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>
4,添加action類
package action;

import com.opensymphony.xwork2.ActionSupport;

public class TestStrutsAction extends ActionSupport {
private static final long serialVersionUID = -5561563641398878951L;

public String execute() throws Exception {
System.out.println("run execute method.....");
return SUCCESS;
}
}
5,配置struts.xml【文件添加到src下面】
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">

<struts>

<constant name="struts.devMode" value="true" />

<package name="default" namespace="/" extends="struts-default">
<action name="index" class="action.TestStrutsAction">
<result name="success">index.jsp</result>
</action>
</package>
</struts>
6,展示一下最後的結構
[img]http://dl.iteye.com/upload/picture/pic/129061/eff60986-e0f5-34ab-ab6b-2c67bc137ae2.jpg[/img]
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章