一、Struts2執行過程圖:

二、struts2配置文件的加載順序
struts-default.xml---struts-plugin.xml---struts.xml
具體步驟:







三、Action中動態方法調用<Dynamic Method Invocation> DMI
第一種方式:
自定義DMIAction類,使它繼承ActionSupport類,該類無需手動重寫execute(),底層有默認實現。因此我們也可以自定義方法list。
struts.xml中的action元素植入method調用前台返回的方法list


若一個類中有多個方法,在struts.xml中需植入多個action元素,因此該方法的安全性低
第二種方式:
在struts.xml中開啟動態方法調用,即可使用一個action,並通過在Action的名稱中使用感嘆號(!)來標識要調用的方法名稱
/*
* 添加圖書
*/
public String add() throws Exception {
System.out.println("======add====");
return "add";
}
/*
* 刪除圖書
*/
public String del() throws Exception {
System.out.println("======del====");
return "del";
}
/*
* 修改圖書
*/
public String edit() throws Exception {
System.out.println("======edit====");
return "edit";
}

執行效果:

四、Action中通配符的使用
通配符用星號(*)表示,用於配置0個或多個字符串,在配置Action時,可以在action元素的name屬性中使用星號來匹配任意的字符串


實現效果:

