bestlong 怕失憶論壇

 

 

搜索
bestlong 怕失憶論壇 論壇 Java [struts2] No result defined for action XXX and resul ...
查看: 3530|回復: 1
go

[struts2] No result defined for action XXX and result input [複製鏈接]

Rank: 9Rank: 9Rank: 9

1#
發表於 2011-4-21 11:13 |只看該作者 |倒序瀏覽 |打印
使用 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
我是雪龍
http://blog.bestlong.idv.tw
http://www.bestlong.idv.tw

Rank: 9Rank: 9Rank: 9

2#
發表於 2011-4-21 11:53 |只看該作者
結果是因為增加了驗證設定檔 EmployeeAction-validation.xml

因為驗證機制是需要輸入
所以當瀏覽的頁面是沒有時
驗證機制就會產生 result input
而 struts.xml 中又沒有設定就會出現此錯誤
‹ 上一主題|下一主題

Archiver|怕失憶論壇

GMT+8, 2024-4-20 12:32 , Processed in 0.022908 second(s), 10 queries .

Powered by Discuz! X1.5

© 2001-2010 Comsenz Inc.