配置的是2.5版本struts2,其余都根据慕友的建议修改了,可以正常运行,在通配符这,一个通配符可以正常运行,使用两个的通配符就报错。请问,这如何解决?
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" "http://struts.apache.org/dtds/struts-2.3.dtd"> <struts> <package name="default" namespace="/" extends="struts-default" strict-method-invocation="false"> <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 com.imooc.action; import com.opensymphony.xwork2.ActionSupport; public class HelloWorldAction extends ActionSupport { public String add() { return "add"; } public String update() { return "update"; } @Override public String execute() throws Exception { System.out.println("执行了Action"); return SUCCESS; } }
自问自答,最后找到了问题,使用的是2.5版本,XML文件配置还是写的2.3dtd,把两个2.3改成2.5就可以了