1.用'!'来定义方法
jsp:
<a href=<%=actionPath%>add!add.action>用!来调用add方法</a><br>
action:
public String add() throws Exception {
return SUCCESS;
}
struts.xml:
<action name="add" class="Login">
<result>
/ActionMethod.jsp
</result>
</action>
2.用通配符来定义方法(相同的action name/action class/result,不同的action method)
jsp:
<a href=<%=actionPath%>person_add.action>personadd 相同的action name/action class/result,不同的action method</a><br>
<a href=<%=actionPath%>person_delete.action>persondelete 相同的action name/action class/result,不同的action method</a><br>
<br>
action:
public String add() throws Exception {
return SUCCESS;
}
public String delete() throws Exception {
return SUCCESS;
}
struts.xml:
<action name="person_*" class="Person" method="{1}">
<result>
/Person.jsp
</result>
</action>
3.用通配符来定义方法(不同的action name/action class/result/action method)
jsp:
<a href=<%=actionPath%>Person_add.action> personadd 不同的action name/action class/result/action method</a><br>
<a href=<%=actionPath%>Person_delete.action>persondelete 不同的action name/action class/result/action method</a><br>
<a href=<%=actionPath%>Book_add.action> bookadd 不同的action name/action class/result/action method</a><br>
<a href=<%=actionPath%>Book_delete.action>bookdelete 不同的action name/action class/result/action method</a><br>
action:
Book:
public String add() throws Exception {
return SUCCESS;
}
public String delete() throws Exception {
return SUCCESS;
}
Person:
public String add() throws Exception {
return SUCCESS;
}
public String delete() throws Exception {
return SUCCESS;
}
struts.xml:
<action name="*_*" class="{1}" method="{2}">
<result>
/{1}.jsp
</result>
</action>