【設定檔】配置ActionMapping

來源:互聯網
上載者:User

ActionMapping對象協助進行架構內部的流程式控制制,它們可將請求URI映射到Action類,並且將Action類與ActionFormbean相關聯。
ActionServlet在內部使用這些映射,並將控制轉移到特定Action類的執行個體。
所有Action類使用perform()方法實現特定應用程式代碼,返回一個ActionForward對象,其中包括響應轉寄的目標資源名稱。
例如:
  <action-mappings>
      <action path="/createBook" type="BookAction" name="bookForm" scope="request" input="/CreateBook.jsp"></action>
              <forward name=”failure” path=”/CreateBook.jsp”/>
              <forward name=”cancel” path=”/index.jsp”/>
  </action-mappings>
    屬性 描述
  Path                Action類的相對路徑
  Name             與本操作關聯的Action bean的名稱
  Type                串連到本映射的Action類的全稱(可有包名)
  Scope             ActionForm bean的範圍(請求或會話)
  Prefix              用來匹配請求參數與bean屬性的首碼
  Suffix              用來匹配請求參數與bean屬性的尾碼
  attribute         範圍名稱。
  className   ActionMapping對象的類的完全限定名預設的類是org.apache.struts.action.ActionMapping
  input               輸入表單的路徑,指向bean發生輸入錯誤必須返回的控制
  unknown       設為true,操作將被作為所有沒有定義的ActionMapping的URI的預設操作
  validate         設定為true,則在調用Action對象上的perform()方法前,ActionServlet將調用ActionForm bean的validate()方法來進行輸入檢查
  通過<forward>元素,可以定義資源的邏輯名稱,該資源是Action類的響應要轉寄的目標。
  屬性 描述
  Id             ID
  ClassName     ActionForward類的完全限定名,預設是org.apache.struts.action.ActionForward
  Name                操作類訪問ActionForward時所用的邏輯名
  Path                   響應轉寄的目標資源的路徑
  redirect             若設定為true,則ActionServlet使用sendRedirect()方法來轉寄資源

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.