在開(kāi)發(fā)中總遇到這個(gè)問(wèn)題,No result defined for action:
原因:Action中的屬性值為空的時(shí)候,Struts2的默認(rèn)攔截器會(huì)報(bào)錯(cuò),但是又找不到input的Result,不能夠把錯(cuò)誤返回,所以報(bào)這種錯(cuò)誤。
解決方法:
1.在頁(yè)面中給空值賦默認(rèn)值。
2.重新定義一個(gè)Action,去掉空值的成員變量。
3.添加input的Result,并在這個(gè)頁(yè)面給出提示
--------------------------------------------------------------------------
當(dāng)你在用struts2開(kāi)發(fā)時(shí),如果,從頁(yè)面跳入action時(shí),頁(yè)面報(bào)No result defined for action and result時(shí),大部分的原因有以下幾種:
1、validate方法沒(méi)有通過(guò);
2、頁(yè)面元素中有重命名時(shí),但后臺(tái)action類的對(duì)應(yīng)的接收此同名參數(shù)的是變量而沒(méi)有寫成數(shù)組
要檢查這種錯(cuò)誤時(shí),可以
1,在后臺(tái)action類中重寫ActionSupport中的
void addActionError(String anErrorMessage)
void addActionMessage(String aMessage)
void addFieldError(String fieldName, String errorMessage)
這三個(gè)方法,在并在其實(shí)現(xiàn)代碼中設(shè)置斷點(diǎn),監(jiān)控傳入的參數(shù),并可獲知頁(yè)面的相關(guān)報(bào)錯(cuò)具體原因.
2,在頁(yè)面中加入以下標(biāo)簽,將錯(cuò)誤顯示出來(lái) :
< div style =”color:red” >
< s:fielderror />
</ div >
--------------------------------------------------------------------------
public void addActionError(String anErrorMessage){
String s=anErrorMessage;
System.out.println(s);
}
public void addActionMessage(String aMessage){
String s=aMessage;
System.out.println(s);
}
public void addFieldError(String fieldName, String errorMessage){
String s=errorMessage;
String f=fieldName;
System.out.println(s);
System.out.println(f);
}
來(lái)自:
原因:Action中的屬性值為空的時(shí)候,Struts2的默認(rèn)攔截器會(huì)報(bào)錯(cuò),但是又找不到input的Result,不能夠把錯(cuò)誤返回,所以報(bào)這種錯(cuò)誤。
解決方法:
1.在頁(yè)面中給空值賦默認(rèn)值。
2.重新定義一個(gè)Action,去掉空值的成員變量。
3.添加input的Result,并在這個(gè)頁(yè)面給出提示
--------------------------------------------------------------------------
當(dāng)你在用struts2開(kāi)發(fā)時(shí),如果,從頁(yè)面跳入action時(shí),頁(yè)面報(bào)No result defined for action and result時(shí),大部分的原因有以下幾種:
1、validate方法沒(méi)有通過(guò);
2、頁(yè)面元素中有重命名時(shí),但后臺(tái)action類的對(duì)應(yīng)的接收此同名參數(shù)的是變量而沒(méi)有寫成數(shù)組
要檢查這種錯(cuò)誤時(shí),可以
1,在后臺(tái)action類中重寫ActionSupport中的
void addActionError(String anErrorMessage)
void addActionMessage(String aMessage)
void addFieldError(String fieldName, String errorMessage)
這三個(gè)方法,在并在其實(shí)現(xiàn)代碼中設(shè)置斷點(diǎn),監(jiān)控傳入的參數(shù),并可獲知頁(yè)面的相關(guān)報(bào)錯(cuò)具體原因.
2,在頁(yè)面中加入以下標(biāo)簽,將錯(cuò)誤顯示出來(lái) :
< div style =”color:red” >
< s:fielderror />
</ div >
--------------------------------------------------------------------------
public void addActionError(String anErrorMessage){
String s=anErrorMessage;
System.out.println(s);
}
public void addActionMessage(String aMessage){
String s=aMessage;
System.out.println(s);
}
public void addFieldError(String fieldName, String errorMessage){
String s=errorMessage;
String f=fieldName;
System.out.println(s);
System.out.println(f);
}
來(lái)自:
http://www.itstrike.cn/Question/9eeeed8e-8a75-4f53-bde7-d0c0a2a6f1e6