[英]Alternative of DispatchAction class in struts2
我從struts1移動到struts2並且我已經在struts2中成功創建了簡單的應用程序我想使用Dispatchaction類的未指定/自定義函數,我在struts2中的struts1中使用它,該類將被擴展為執行此操作
不會延長課程; 在操作配置中使用“method”屬性 ,或者如果使用基於注釋的配置 ,則直接注釋方法。 您還可以使用通配符操作來避免手動配置。
如果這對您不起作用,請具體說明您的需求,以及為什么不起作用。
DispatchAction
幫助我們將一組相關函數分組到一個操作中。 在Struts 2中,默認情況下所有Actions都提供此功能。 要使用此功能,我們需要使用execute()方法的類似簽名創建不同的方法,只更改方法的名稱。
例如,您可以創建一個用戶處理操作,其中包括創建,刪除更新用戶等方法
public class UserAction extends ActionSupport{
private String methodName;
public String execute()
{
methodName= "Inside execute method";
return SUCCESS;
}
public String add()
{
methodName= "Inside add method";
return SUCCESS;
}
public String update()
{
methodName= "Inside update method";
return SUCCESS;
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.