通配符问题
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd"> <struts> <package name="default" namespace="/" extends="struts-default"> <!-- action默认的method ="execute"--> <action name="index_*" method="{1}" class="com.action.HelloWorldAction"> <result name="add">/{1}.jsp</result> <result name="update">/{1}.jsp</result> <result> /HelloWorld.jsp</result> </action> </package> </struts>
package com.action; import com.opensymphony.xwork2.ActionSupport; @SuppressWarnings("serial") public class HelloWorldAction extends ActionSupport { @Override public String execute() throws Exception { System.out.println("执行成功"); return SUCCESS; } public String add() throws Exception { System.out.println("add执行成功"); return SUCCESS; } public String update() throws Exception { System.out.println("update执行成功"); return SUCCESS; } }
但是无论输入index_add 还是index_update 还是跳转到HelloWorld.jsp