javax.servlet.jsp.JspException: Cannot retrieve mapping for action /Login
可能原因:Action 未在 struts-config.xml 定義,或找不到匹配 Action。例:JSP 用 <html:form action="login.do"> 提交至 login.do 但配置缺失。
處理:檢查 struts-config.xml 定義,注意拼字錯誤或不符規範,可用 StrutsConsole 工具檢查。
org.apache.jasper.JasperException: Cannot retrieve definition for form bean null
可能原因:Struts 依 struts-config.xml mapping 找不到 Action 期望的 FormBean。多數因 form-bean 的 name 與 action 的 name 不匹配(含大小寫)。Action 與 Form 各需精確匹配的 name。若 Action 做流程控制(如依參數跳轉)而非處理表單,可無 name 屬性。
No action instance for path /xxxx could be created
可能原因:情況眾多,建議調高 Web Server 日誌/除錯等級以獲取更多潛在錯誤資訊。struts-config.xml 中 action 標籤 class 屬性指定的類別找不到,原因包括:
.class 檔未在 classpath(Web 開發中 class 位於 WEB-INF/classes,Action class 必須在該目錄。例:WEB-INF/classes/action/Login.class → type="action.Login")。Action 類別。WEB-INF/classes/)。javax.servlet.jsp.JspException: No getter method for property username of bean org.apache.struts.taglib.html.BEAN
可能原因:FormBean 中某變數缺少 getter 方法。使用 <html:text property="username"> 時,FormBean 必須有 getUsername() 方法(注意大寫 U)。
可能原因:通常因 struts-config.xml 未正確載入或路徑錯誤,檢查 web.xml 中 ActionServlet 的 init-param config 參數路徑是否正確。