1.下载Struts2
到Apache Struts2官网下载最新的Struts2
import com.opensymphony.xwork2.ActionSupport; public class MyAction extends ActionSupport { private static final long serialVersionUID = 1L; public String execute(){ return SUCCESS; } }
4)编写struts.xml,打开src文件夹下的struts.xml文件,Code如下:
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd"> <struts> <package name="main" extends="struts-default"> <action name="MyAction" class="MyAction"> <result name="success">/index.jsp</result> </action> </package> </struts>
5)启动Tomcat服务器并运行TestStruts2
参考: