公眾號:mywangxiao
及時發(fā)布考試資訊
分享考試技巧、復(fù)習(xí)經(jīng)驗(yàn)
新浪微博 @wangxiaocn關(guān)注微博
聯(lián)系方式 400-18-8000
可能原因
沒有位form bean中的某個變量定義getter 方法
這個錯誤主要發(fā)生在表單提交的FormBean中,用struts標(biāo)記html:text property=”username”時,在FormBean中必須有一個getUsername()方法。注意字母“U”。
異常
java。lang。NoClassDefFoundError: org/apache/struts/action/ActionForm
可能原因
這個錯誤主要發(fā)生在在classpath中找不到相應(yīng)的Java 。class文件。如果這個錯誤發(fā)生在web應(yīng)用程序的運(yùn)行時,主要是因?yàn)橹付ǖ腸lass文件不在web server的classpath中(/WEBINF/classes 和 /WEBINF/lib)。在上面的錯誤中,原因是找不到ActionForm類。
異常
javax。servlet。jsp。JspException: Exception creating bean of class org。apache。struts。action。ActionForm: {1}
可能原因
Instantiating Strutsprovided ActionForm class directly instead of instantiating a class derived off ActionForm。 This mightoccur implicitly if you specify that a formbean is this Struts ActionForm class rather than specifying a child of this classfor the formbean。
Not associating an ActionFormdescended class with an action can also lead to this error。
異常
javax。servlet。jsp。JspException: Cannot find ActionMappings or ActionFormBeans collection
可能原因
不是標(biāo)識Struts actionServlet的servlet標(biāo)記就是映射。do擴(kuò)展名的sevletmapping標(biāo)記或者兩者都沒有在web。xml中聲明。
在strutsconfig。xml中的打字或者拼寫錯誤也可導(dǎo)致這個異常的發(fā)生。例如缺少一個標(biāo)記的關(guān)閉符號/。最好使用struts console工具檢查一下。
另外,loadonstartup必須在web。xml中聲明,這要么是一個空標(biāo)記,要么指定一個數(shù)值,這個數(shù)值用來表servlet運(yùn)行的優(yōu)先級,數(shù)值越大優(yōu)先級越低。
還有一個和使用loadonstartup有關(guān)的是使用Struts預(yù)編譯JSP文件時也可能導(dǎo)致這個異常。
異常
java。lang。NullPointerException at org。apache。struts。util。RequestUtils。forwardURL(RequestUtils。java:1223)
可能原因
在strutsconfig。xml中的forward元素缺少path屬性。例如應(yīng)該是如下形式:
forward name="userhome" path="/user/userhome。jsp"/
異常
javax。servlet。jsp。JspException: Cannot find bean org。apache。struts。taglib。html。BEAN in any scope
Probable Causes
試圖在Struts的form標(biāo)記外使用form的子元素。這常常發(fā)生在你在/html:form后面使用Struts的html標(biāo)記。另外要注意可能你不經(jīng)意使用的無主體的標(biāo)記,如html:form … /,這樣web 服務(wù)器解析時就當(dāng)作一個無主體的標(biāo)記,隨后使用的所有html標(biāo)記都被認(rèn)為是在這個標(biāo)記之外的,如又使用了html:text property=”id”還有就是在使用taglib引入HTML標(biāo)記庫時,你使用的prefix的值不是html。
編輯推薦:JAVA認(rèn)證考試經(jīng)驗(yàn)技巧之JAVA常見異常匯總
更多關(guān)注:JAVA考試經(jīng)驗(yàn) JAVA輔導(dǎo)資料 JAVA歷年真題
(責(zé)任編輯:xy)