struts2開發流程

    使用struts2不難,大體就分爲如下幾步:web

    1)在web.xml中定義struts2的核心攔截器,這與SpringMVC很類似,SpringMVC經過spring

    org.springframework.web.servlet.DispatcherServlet攔截,而struts2則經過apache

    org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter進行攔截。它不單對*.action頁面進行攔截,若須要已post方式提交請求,則需對相應的*.jsp頁面進行攔截。jsp

    2)定義處理數據的Action(繼承ActionSupport)重寫execute方法便可;post

    3)配置Action處理返回數據與物理試圖對應關係,一般使用struts.xml進行配置,<action name="" class=""><result name="input">test.jsp</result></action>spa

    4)編寫視圖xml

相關文章
相關標籤/搜索