首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 編程語言 >  >> Java 程式設計 >> Java 相關知識

Struts 常見錯誤彙總與解決方案

     編輯:Java 相關知識

Top 11 常見異常

  1. No bean found under attribute key XXX:struts-config.xml 中 ActionForm type 指定類不存在,或 Action 定義中 name/attribute 引用的 Form 不存在。
  2. Cannot find bean XXX in any scope:JSP 試圖獲取未在 Action 中 setAttribute 的對象。檢查標簽 name 屬性或 getAttribute 參數;或 Action 邏輯未執行設值就轉向。
  3. Missing message for key "XXX":ApplicationResources.properties 缺少 JSP 需要的資源鍵。多模塊時需在模塊 struts-config-xxx.xml 指定資源文件。
  4. No getter method for property XXX of bean YYY:JSP 標簽 property 指定的屬性在 Bean 中不存在(如拼寫錯誤 cade vs code)。
  5. Cannot find ActionMappings or ActionFormBeans collection:待解決。
  6. Cannot retrieve mapping for action XXX:JSP <html:form action="/XXX"> 對應的 Action 未在 struts-config.xml 定義。
  7. HTTP Status 404 - /xxx/xxx.jsp:Forward path 指向的 JSP 不存在。同模塊轉向不含模塊名;跨模塊需 contextRelative="true"。
  8. 空白頁面無異常:Action 使用的 forward 名稱與配置不匹配。
  9. The element type "XXX" must be terminated...:struts-config.xml XML 格式錯誤,檢查是否良構。
  10. Servlet.init() for servlet action threw exception:常伴隨 ActionServlet 堆疊。例:struts-config.xml 遺失(CVS 同步誤刪)。
  11. Resources not defined for Validator:Validator 插件異常,檢查 validation.xml 資源定義、form 名稱。

除錯建議

  • 善用 Struts 源碼斷點定位(如 ActionServlet.parseModuleConfigFile)
  • 檢查配置文件同步與完整性
  • 資源文件名稱與路徑大小寫敏感
  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved