首先写两个类
student
public class Student extends ActionSupport{
public String add(){
System.out.println("student add");
return SUCCESS;
}
public String delete(){
System.out.println("student delete");
return SUCCESS;
}
}
teacher
public class Teacher extends ActionSupport{
public String add(){
System.out.println("teacher add");
return SUCCESS;
}
public String delete(){
System.out.println("teacher delete");
return SUCCESS;
}
}
在写struts.xml
<struts>
<constant name="struts.devMode" value="true" />
<package name="test_1" namespace="/actionWildcard" extends="struts-default">
<action name="*_*" class="com.sl.actionWildcard.{1}" method="{2}">
<result name="success">/{1}_{2}.jsp</result>
</action>
</package>
</struts>
再分别写Student_add.jsp Student_delete.jsp Teacher_add.jsp Teacher_delete.jsp