简单的HelloAction 的实现:
1)创建包结构……
com.sun.entity
com.sun.dao
com.sun.action
2)复制struts2的核心包
xwork-core-2.1.6.jar
struts2-core-2.1.8.1.jar
ognl-2.7.3.jar
freemarker-2.3.15.jar
commons-fileupload-1.2.1.jar
javassist-3.11.0.GA.jar
3)配载前端控制器(FC)
<filter>
<filter-name>fc</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>fc</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
4) 编写Struts2的配置文件,用XML的方式声明控制逻辑
<package name="p1"extends="struts-default" namespace="/core">
<actionname="hello" class="com.tarena.tts.action.HelloAction"
method="go">
<resultname="r1">/jsp/one.jsp</result>
<resultname="r2">/jsp/two.jsp</result>
</action>
</package>
</struts>
5) 编写Action类和JSP页面