struts2的jar包用的是2.5的
HTTP Status 404 - There is no Action mapped for namespace [/] and action name [HelloWorld_add_action] associated with context path [/HelloWorld].
HelloWorldAction.java
public class HelloWorldAction extends ActionSupport { // helloworld.action @Override public String execute() throws Exception { System.out.println("执行Action"); return SUCCESS; } public String add() { return "add"; } public String update() { return "update"; } }
struts.xml
<struts> <package name="default" namespace="/" extends="struts-default"> <action name="*_*" method="{2}" class="com.imooc.action.{1}Action"> <result >/result.jsp</result> <result name="add">/{2}.jsp</result> <result name="update">/{2}.jsp</result> </action> </package> <constant name="struts.enable.DynamicMethodInvocation" value="false"></constant> </struts>
正解,亲测有效,在package标签加上属性即可成功运行
strict-method-invocation="false"
在package节点中添加属性strict-method-invocation="false"就可以了
已解决,换成2.3的jar包可以,新的问题,2.5为什么不可以,是不支持2,3种方式,还是增强了安全性,有些属性没有设置呢?