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 中的設定
  1.         <action name="employee" class="action.EmployeeAction">
  2.                 <result name="add">/WEB-INF/view/employee-add.jsp</result>
  3.                 <result name="edt">/WEB-INF/view/employee-add.jsp</result>
  4.                 <result>/WEB-INF/view/employee.jsp</result>
  5.         </action>
複製代碼
在 Action 的相關程式碼部分
  1. package action;
  2. public class EmployeeAction extends BaseAction implements SessionAware {
  3.         public static final String ADD = "add";
  4.         public static final String EDIT = "edt";
  5.         private Employee employee = null;

  6.         public String execute() {
  7.                 System.out.println("CHECK");
  8.                 if(ADD.equals(action)) {
  9.                         this.employee = null;
  10.                         return ADD;
  11.                 }
  12.                 if(EDIT.equals(action)) {
  13.                         this.employee = dao.findById(this.id);
  14.                         return EDIT;
  15.                 }
  16.                 return SUCCESS;
  17.         }
  18. }
複製代碼
不知道為何會去找 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