Struts2學習之路(三)—— Action方法調用

來源:互聯網
上載者:User

標籤:

上一篇(http://www.cnblogs.com/denisechen/p/4644275.html)提到,action執行的時候並不一定要執行execute方法。那麼該如何決定要調用的方法?有以下三種方式:

1.使用method屬性指定具體方法

這種方法會使得建立的action非常多。

1 <action name="order" class="com.action.Order" method="add">2     <result name="add">/success.jsp</result>3 </action>

2.動態方法引動過程(DMI)

action中並無特別,一個action下可以包含多個result。

1 <action name="order" class="com.action.Order"> 2     <result name="add">/add.jsp</result> 3     <result name="delete">/delete.jsp</result> 4 </action> 

使用!存取方法,以下是jsp檔案中調用樣本:

1 <a href="order!add.action">  添加訂單  </a>2 <a href="order!delete.action"> 刪除訂單</a>

3.使用萬用字元(推薦)

 使用{}括弧裡加數位方式,可以有多個萬用字元,按順序匹配。

1 <action name="order*" class="com.action.Order" method="{1}">2             <result name="{1}">/order{1}.jsp</result>3 </action>

在jsp中調用時:

1 <a href="orderadd.action">  添加訂單  </a>2 <a href="orderdelete.action"> 刪除訂單</a>

 

Struts2學習之路(三)—— Action方法調用

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.