方法类:
package Action;
import com.opensymphony.xwork2.ActionSupport;
public class test extends ActionSupport {
public String execute() throws Exception {
System.out.print("executed");
return SUCCESS;
}
public String add(){
return SUCCESS;
}
}
配置文件:
<?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>
<package name="defult" namespace="/" extends="struts-default">
<action name="test" class="Action.test">
<result>/test.jsp</result>
</action>
<action name="add" method="add" class="Action.test">
<result>/add.jsp</result>
</action>
</package>
</struts>
url:http://localhost:8080/MyfirstStruts2/add.action