struts2的使用技巧:struts.xml配置文件的編輯

如果在struts.xml文件中<action>沒有method屬性,例如:<action name="helloWorld"  class="action.HelloWorld">,那麼在HelloWorld.java中默認必須具有public String execute()方法;

如果具有method屬性,可以不用寫execute()方法,例如:<action name="helloWorld" class="action.HelloWorld" method="hello">,那麼在HelloWorld.java中具有public String hello()方法就可以了;

也可以在HelloWorld.java中寫多個方法,然後在action中根據name的不同,選用不同的method。

發佈了58 篇原創文章 · 獲贊 6 · 訪問量 6萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章