bestlong 怕失憶論壇
標題:
[struts2] No result defined for action XXX and result input
[打印本頁]
作者:
bestlong
時間:
2011-4-21 11:13
標題:
[struts2] No result defined for action XXX and result input
使用 struts 2.2.1.1 持續的增加程式, 瀏覽原本正常的 /webapp/employee.action 畫面突然出現錯誤
No result defined for action action.EmployeeAction and result input
當時在 struts.xml 中的設定
<action name="employee" class="action.EmployeeAction">
<result name="add">/WEB-INF/view/employee-add.jsp</result>
<result name="edt">/WEB-INF/view/employee-add.jsp</result>
<result>/WEB-INF/view/employee.jsp</result>
</action>
複製代碼
在 Action 的相關程式碼部分
package action;
public class EmployeeAction extends BaseAction implements SessionAware {
public static final String ADD = "add";
public static final String EDIT = "edt";
private Employee employee = null;
public String execute() {
System.out.println("CHECK");
if(ADD.equals(action)) {
this.employee = null;
return ADD;
}
if(EDIT.equals(action)) {
this.employee = dao.findById(this.id);
return EDIT;
}
return SUCCESS;
}
}
複製代碼
不知道為何會去找 result input
作者:
bestlong
時間:
2011-4-21 11:53
結果是因為增加了驗證設定檔 EmployeeAction-validation.xml
因為驗證機制是需要輸入
所以當瀏覽的頁面是沒有時
驗證機制就會產生 result input
而 struts.xml 中又沒有設定就會出現此錯誤
歡迎光臨 bestlong 怕失憶論壇 (http://www.bestlong.idv.tw/)
Powered by Discuz! X1.5