1.不适用通配符的配置
<!-- ############通配符的使用 -->
<action name="Useraction-save" method="save"
class="com.huangliusong.struts2.Useraction.UserAction">
<result name="save-success">/WEB-INF/pages/login-success.jsp</result>
</action>
<action name="Useraction-update" method="update"
class="com.huangliusong.struts2.Useraction.UserAction">
<result name="update-success">/WEB-INF/pages/login-success.jsp</result>
</action>
<action name="Useraction-delete" method="delete"
class="com.huangliusong.struts2.Useraction.UserAction">
<result name="delete-success">/WEB-INF/pages/login-success.jsp</result>
</action>
<action name="Useraction-query" method="query"
class="com.huangliusong.struts2.Useraction.UserAction">
<result name="query-success">/WEB-INF/pages/login-success.jsp</result>
</action>
2.UserAction.java
package com.huangliusong.struts2.Useraction;
public class UserAction {
public String save(){
System.err.println("save");
return "save-success";
}
public String update(){
System.err.println("update");
return "update-success";
}
public String query(){
System.err.println("query");
return "query-success";
}
public String delete(){
System.err.println("delete");
return "delete-success";
}
}
3.index.jsp
<a href="Useraction-save.do">Useraction-save</a> <br>
<a href="Useraction-update.do">Useraction-update</a> <br>
<a href="Useraction-delete.do">Useraction-delete</a> <br>
<a href="Useraction-query.do">Useraction-query</a> <br>
效果