Action代码
public class HelloWorldAction extends ActionSupport {
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
public String execute() throws Exception {
System.out.println("执行Action");
return SUCCESS;
}
//添加
public String add(){
System.out.println("执行ADD");
return "add";
}
//更新
public String update(){
System.out.println("执行UPDATE");
return "update";
}
}
struts配置的代码
<struts>
<package name="default" namespace="/" extends="struts-default">
<action name="helloWorld" class="com.hao.action.HelloWorldAction">
<result>/result.jsp</result>
<result name="add">/add.jsp</result>
<result name="update">/update.jsp</result>
</action>
</package>
<constant name="struts.enable.DynamicMethodInvocation" value="true"></constant>
</struts>
运行后访问 http://127.0.0.1:8080/HelloWorld/helloWorld!add
报错提示无效的方法
你加上后缀.action试试