1、用的 struts2-core-2.3.30.jar包
2、
public String add(){ return SUCCESS; } public String update(){ return SUCCESS; } @Override public String execute() throws Exception { System.out.println("=====执行action"); return SUCCESS; }
3、
<package strict-method-invocation="false" name="default" namespace="/" extends="struts-default"> <action name="helloworld_*" method="{1}" class="com.twx.action.HelloWorld"> <result name="add">/{1}.jsp</result> <result name="update">/{1}.jsp</result> <result>/HelloWorld.jsp</result> </action> <!-- <action name="addAction" method="add" class="com.twx.action.HelloWorld"> <result>/add.jsp</result> </action> <action name="updateAction" method="update" class="com.twx.action.HelloWorld"> <result>/update.jsp</result> </action> --> </package> <constant name="struts.enable.DynamicMethodInvocation" value="false"></constant>
4、访问 http://localhost:8080/Struts2Demo/helloworld_add.action 时,并没有跳转到add.jsp页面
而是跳转到HelloWorld.jsp页面
Caballarii