1、在新建的项目上点右键,然后选择MyEclipse->Add Struts capabilities
2、在struts配置窗口中选择struts 2.1,然后点Finish
在这一步,myeclipse在web.xml文件中配置struts2过滤器,增加的内容如下:
<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>*.action</url-pattern></filter-mapping>
另外,myeclipse还在工程的src目录新建了struts.xml文件,这个文件是用来配置action的。当然了,myeclipse还做了一件事情,就是把支持struts2的jar包都导入到工程中。
3、编写action类