使用action标签method属性
1、创建action,创建多个方法
package zmx.itcast.method;
import com.opensymphony.xwork2.ActionSupport;
public class BookAction extends ActionSupport{
//添加
public String add(){
System.out.println("add..................");
return NONE;
}
//修改
public String update(){
System.out.println("update..........11111");
return NONE;
}
}
2 使用method配置
<?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>
<package name="methoddemo" extends="struts-default" namespace="/">
<!-- 有method属性,写要执行的action里面的方法的名称 -->
<action name="addAction" class="zmx.itcast.method.BookAction" method="add"></action>
</package>
</struts>