Struts2萬用字元 Struts2動態方法呼叫

2021-08-24 19:29:58 字數 919 閱讀 9798

形式一:呼叫相同action中的不同方法

/login.jsp

/error.jsp

/welcome.jsp

其中表示式的值name屬性值中第乙個*的值。

如果使用者請求的url為loginaction.action,則呼叫jcuckoo.loginregistaction中的login方法;

如果使用者請求的url為registeraction.action,則呼叫jcuckoo.loginregistaction中的register方法;

形式二:通過匹配,呼叫不同的action的execute方法

/login.jsp

/error.jsp

/welcome.jsp

上面沒有出現method屬性,故預設呼叫對應的execute方法

如果使用者請求的url為loginaction.action,則呼叫jcuckoo.loginaction中的execute方法;

如果使用者請求的url為registeraction.action,則呼叫jcuckoo.registeraction中的execute方法;

形式三:相同action動態結果

/input.jsp

/.jsp

當處理結果是input時,會轉到/input.jsp頁面

當處理結果是success時,

如果crud_create.action,則會執行jcuckoo.crudaction中的create方法,並且跳轉到/create.jsp;

如果crud_delete.action,則會執行jcuckoo.crudaction中的delete方法,並且跳轉到/delete.jsp; 

struts2 萬用字元用法

原理 用 來填充佔位符,出現的第乙個 對應,第二個 對應 例子 action name crud class example.crud method 當頁面中請求crud input.action時,就會自動去找action的input方法,當遇到crud delete時,就會自動去找action的...

Struts2萬用字元配置

name edit class org.apache.struts 萬用字元中幾個特殊的標記,如下所述 可以匹配0個或多個任意字元,但是不包括正斜槓 可以匹配0個或多個任意字元,包括正斜槓 在內 反斜槓,轉義字元。因為 不能匹配正斜槓,所以前面 editsubscription add不會被匹配上。...

struts2 萬用字元對映

小哥叫我閱讀專案伺服器端的 發現struts.xml中有 這個是什麼意思呢?name guestroommsg 代表這個action處理以guestroommsg 開頭的請求 入 guestroommsg getname 等 method 表示根據guestroommsg methodname 訪問...