關(guān)于通配符的
<action name="4b.*" ?method="{1}" class="com.struts.Struts">
<result >/strutst2.jsp</result>
<result name="add">/add.jsp</result>
<result name="update">/update.jsp</result>
我這樣寫的,不管是訪問4b.add.action還是4b.update.action都是跳到struts2.jsp這個頁面
下面是java代碼
package com.struts;
import java.awt.event.ActionEvent;
import com.opensymphony.xwork2.ActionSupport;
public class Struts extends ActionSupport{
/**
*?
*/
private static final long serialVersionUID = 1L;
@Override
public String execute() throws Exception {
// TODO Auto-generated method stub
System.out.println("chixing");
return SUCCESS;
}
public String add(){
System.out.println("這是add方法");
return SUCCESS;
}
public String update(){
System.out.println("這是一個update方法");
return SUCCESS;
}
}
2016-10-19
就把Action中方法的返回String 換成對應(yīng)jsp的name值就好了
2016-08-05
對啊,都被execute()方法攔截執(zhí)行了