<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆 - 251  文章 - 504  trackbacks - 0
    <2006年7月>
    2526272829301
    2345678
    9101112131415
    16171819202122
    23242526272829
    303112345

    本博客系個(gè)人收集材料及學(xué)習(xí)記錄之用,各類“大俠”勿擾!

    留言簿(14)

    隨筆分類

    收藏夾

    My Favorite Web Sites

    名Bloger

    非著名Bloger

    搜索

    •  

    積分與排名

    • 積分 - 202520
    • 排名 - 285

    最新評(píng)論

    本篇文章包含了在用Struts開發(fā)web應(yīng)用時(shí)經(jīng)常碰到的一些異常和錯(cuò)誤,根據(jù)異常或錯(cuò)誤信息本身,經(jīng)常可以找到潛在的錯(cuò)誤發(fā)生原因。

    下面列出了一些Struts的常見錯(cuò)誤和異常,并給出了一些可能發(fā)生此類錯(cuò)誤或異常的原因。有的后面有相關(guān)連接,你可以通過它找到更多的信息。

    Cannot retrieve mapping for action

    異常

    javax.servlet.jsp.JspException: Cannot retrieve mapping for action /Login /Login 是你的 action 名字)

    ?

    ?

    可能原因

    action 沒有再 struts-config.xml 中定義,或沒有找到匹配的 action ,例如在 JSP 文件中使用 <html:form action=" Login.do " . 將表單提交給 Login.do 處理,如果出現(xiàn)上述異常,請(qǐng)查看 struts-config.xml 中的定義部分,有時(shí)可能是打錯(cuò)了字符或者是某些不符合規(guī)則,可以使用 struts console 工具來檢查。

    ?

    Cannot retrieve definition for form bean null

    異常

    org.apache.jasper.JasperException: Cannot retrieve definition for form bean null

    可能原因 ???????
    ? ??????

    這個(gè)異常是因?yàn)?/span> Struts 根據(jù) struts-config.xml 中的 mapping 沒有找到 action 期望的 form bean 。大部分的情況可能是因?yàn)樵?/span> form-bean 中設(shè)置的 name 屬性和 action 中設(shè)置的 name 屬性不匹配所致。換句話說, action form 都應(yīng)該各自有一個(gè) name 屬性,并且要精確匹配,包括大小寫。這個(gè)錯(cuò)誤當(dāng)沒有 name 屬性和 action 關(guān)聯(lián)時(shí)也會(huì)發(fā)生,如果沒有在 action 中指定 name 屬性,那么就沒有 name 屬性和 action 相關(guān)聯(lián)。當(dāng)然當(dāng) action 制作某些控制時(shí),譬如根據(jù)參數(shù)值跳轉(zhuǎn)到相應(yīng)的 jsp 頁面,而不是處理表單數(shù)據(jù),這是就不用 name 屬性,這也是 action 的使用方法之一。

    ?

    No action instance for path /xxxx could be created

    異常

    No action instance for path /xxxx could be created

    可能原因

    特別提示:因?yàn)橛泻芏嘀星闆r會(huì)導(dǎo)致這個(gè)錯(cuò)誤的發(fā)生,所以推薦大家調(diào)高你的 web 服務(wù)器的日志 / 調(diào)試級(jí)別,這樣可以從更多的信息中看到潛在的、在試圖創(chuàng)建 action 類時(shí)發(fā)生的錯(cuò)誤,這個(gè) action 類你已經(jīng)在 struts-config.xml 中設(shè)置了關(guān)聯(lián)(即添加了 <action> 標(biāo)簽)。

    struts-config.xml 中通過action標(biāo)簽的class屬性指定的action類不能被找到有很多種原因,例如:

    • 定位編譯后的 .class 文件失敗。 Failure to place compiled .class file for the action in the classpath ( web 開發(fā)中, class 的的位置在 r WEB-INF/classes, 所以你的action class必須要在這個(gè)目錄下。例如你的action類位于WEB-INF/classes/action/Login.class,那么在struts-config.xml中設(shè)置action的屬性type時(shí)就是action.Login ).
    • 拼寫錯(cuò)誤,這個(gè)也時(shí)有發(fā)生,并且不易找到,特別注意第一個(gè)字母的大小寫和包的名稱。

    struts-config.xml中指定的action類沒有繼承自Stuts的Action類,或者你自定義的Action類沒有繼承自Struts提供的Action類。

    你的action類必須繼承自Struts提供的Action類。

    你的classpath的問題。例如web server沒有發(fā)現(xiàn)你的資源文件,資源文件必須在 WEB-INF/classes/目錄下

    Problem in struts-config.xml file with action mapping.

    Problem with data-sources.xml file.

    相關(guān)鏈接

    ?

    No getter method for property XXXX of bean org.apache.struts.taglib.html.BEAN

    異常

    javax.servlet.jsp.JspException: No getter method for property username of bean org.apache.struts.taglib.html.BEAN

    可能原因

    沒有位 form bean 中的某個(gè)變量定義 getter 方法

    這個(gè)錯(cuò)誤主要發(fā)生在表單提交的 FormBean 中,用 struts 標(biāo)記 <html:text property=”username”> 時(shí),在 FormBean 中必須有一個(gè) getUsername() 方法。注意字母“ U ”。

    Related Links

    ?

    java.lang.NoClassDefFoundError: org/apache/struts/action/ActionForm

    錯(cuò)誤

    java.lang.NoClassDefFoundError: org/apache/struts/action/ActionForm

    可能原因

    這個(gè)錯(cuò)誤主要發(fā)生在在 classpath 中找不到相應(yīng)的 Java .class 文件。如果這個(gè)錯(cuò)誤發(fā)生在 web 應(yīng)用程序的運(yùn)行時(shí),主要是因?yàn)橹付ǖ?/span> class 文件不在 web server classpath 中( /WEB-INF/classes /WEB-INF/lib)。

    在上面的錯(cuò)誤中,原因是找不到ActionForm類。

    This error is sometimes seen when one or more ActionForm.class instances are actually in the classpath. This most often occurs when ActionForm.class is made available correctly by placing struts.jar in the /WEB-INF/lib directory. When this library has been correctly placed and it is verified that ActionForm.class actually is present in the struts.jar file, the problem is either that more than one copy of ActionForm.class is in the classpath or (more likely) that duplicate versions of class files other than ActionForm are in the same classpath, causing confusion. This is especially true if a class that extends ActionForm is made available twice, such as in an .ear file that encompasses a .war file as well as in the .war file's own classpath ( /WEB-INF/classes ). This problem can be resolved by guaranteeing that there are no redundant classes, especially those related to Struts (directly from Struts or extensions of Struts), in the web application's view.

    相關(guān)連接

    ?

    Exception creating bean of class org.apache.struts.action.ActionForm: {1}

    異常

    javax.servlet.jsp.JspException: Exception creating bean of class org.apache.struts.action.ActionForm: {1}

    可能原因

    Instantiating Struts-provided ActionForm class directly instead of instantiating a class derived off ActionForm . This might occur implicitly if you specify that a form-bean is this Struts ActionForm class rather than specifying a child of this class for the form-bean.

    Not associating an ActionForm -descended class with an action can also lead to this error.

    Related Links

    ?

    ?

    Cannot find ActionMappings or ActionFormBeans collection

    Exception

    javax.servlet.jsp.JspException: Cannot find ActionMappings or ActionFormBeans collection

    可能原因

    不是標(biāo)識(shí) Struts actionServlet <servlet> 標(biāo)記就是映射 .do 擴(kuò)展名的 <sevlet-mapping> 標(biāo)記或者兩者都沒有在 web.xml 中聲明。

    struts-config.xml 中的打字或者拼寫錯(cuò)誤也可導(dǎo)致這個(gè)異常的發(fā)生。例如缺少一個(gè)標(biāo)記的關(guān)閉符號(hào) /> 最好使用 struts console 工具檢查一下

    另外, load-on-startup 必須在 web.xml 中聲明,這要么是一個(gè)空標(biāo)記,要么指定一個(gè)數(shù)值,這個(gè)數(shù)值用來表 servlet 運(yùn)行的優(yōu)先級(jí),數(shù)值越大優(yōu)先級(jí)越低。

    還有一個(gè)和使用 load-on-startup 有關(guān)的是使用 Struts 預(yù)編譯 JSP 文件時(shí)也可能導(dǎo)致這個(gè)異常。

    相關(guān)鏈接

    ?

    NullPointerException at ... RequestUtils.forwardURL

    異常

    java.lang.NullPointerException at org.apache.struts.util.RequestUtils.forwardURL(RequestUtils.java:1223)

    可能原因

    struts-config.xml 中的 forward 元素缺少 path 屬性。例如應(yīng)該是如下形式:
    <forward name="userhome" path="/user/userhome.jsp"/>

    ?

    Cannot find bean org.apache.struts.taglib.html.BEAN in any scope

    Exception

    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ù)器解析時(shí)就當(dāng)作一個(gè)無主體的標(biāo)記,隨后使用的所有<html>標(biāo)記都被認(rèn)為是在這個(gè)標(biāo)記之外的,如又使用了<html:text property=”id”>

    還有就是在使用taglib引入HTML標(biāo)記庫(kù)時(shí),你使用的prefix的值不是html。?

    相關(guān)連接

    ?

    Missing message for key xx.xx.xx

    Exception

    javax.servlet.jsp.JspException: Missing message for key xx.xx.xx

    Probable Causes

    這個(gè) key 的值對(duì)沒有在資源文件 ApplicationResources.properties 中定義。如果你使用 eclipse 時(shí)經(jīng)常碰到這樣的情況,當(dāng)項(xiàng)目重新編譯時(shí), eclipse 會(huì)自動(dòng)將 classes 目錄下的資源文件刪除。

    資源文件 ApplicationResources.properties 不在 classpath 應(yīng)將資源文件放到 WEB-INF/classes 目錄下,當(dāng)然要在 struts-config.xml 中定義 )

    ?

    Cannot find message resources under key org.apache.struts.action.MESSAGE

    異常

    Cannot find message resources under key org.apache.struts.action.MESSAGE

    可能原因

    很顯然,這個(gè)錯(cuò)誤是發(fā)生在使用資源文件時(shí),而 Struts 沒有找到資源文件。

    Implicitly trying to use message resources that are not available (such as using empty html:options tag instead of specifying the options in its body -- this assumes options are specified in ApplicationResources.properties file)

    XML parser issues -- too many, too few, incorrect/incompatible versions

    Related Links

    ?

    No input attribute for mapping path /loginAction

    錯(cuò)誤

    No input attribute for mapping path /xxxxAction

    可能原因 e

    No input attribute in action mapping in struts-config.xml file for the action with the name specified in the error message. An input attribute is not required if form validation is not performed (either because the validate attribute is set to false or because the validation method in the relevant form class is not implemented. The input attribute specifies the page leading to this action because that page is used to display error messages from the form validation.

    Related Links

    ?

    ?

    Strange Output Characters

    錯(cuò)誤

    Strange and seemingly random characters in HTML and on screen, but not in original JSP or servlet.

    可能原因

    混和使用 Struts html:form 標(biāo)記和標(biāo)準(zhǔn)的 HTML 標(biāo)記不正確。

    使用的編碼樣式在本頁中不支持。

    ?

    "Document contained no data" or no data rendered on page

    錯(cuò)誤

    "Document contained no data" in Netscape

    No data rendered (completely empty) page in Microsoft Internet Explorer

    可能原因

    使用一個(gè) Action 的派生類而沒有實(shí)現(xiàn) perform() 方法或 execute() 方法。在 Struts1.0 中實(shí)現(xiàn)的是 perform() 方法,在 Struts1.1 中實(shí)現(xiàn)的是 execute() 方法,但 Struts1.1 向后兼容 perform() 方法。

    但你使用 Struts1.1 創(chuàng)建一個(gè) Action 的派生類,并且實(shí)現(xiàn)了 execute() 方法,而你在 Struts1.0 中運(yùn)行的話,就會(huì)得到 "Document contained no data" error message in Netscape or a completely empty (no HTML whatsoever) page rendered in Microsoft Internet Explorer.” 的錯(cuò)誤信息。

    ?

    posted on 2006-07-24 12:26 matthew 閱讀(260) 評(píng)論(0)  編輯  收藏 所屬分類: JavaEE
    主站蜘蛛池模板: ww在线观视频免费观看| 91av免费在线视频| 亚洲精品永久www忘忧草| GOGOGO免费观看国语| 亚洲免费视频一区二区三区| 曰批全过程免费视频观看免费软件| selaoban在线视频免费精品| 国产自产拍精品视频免费看| 亚洲综合区小说区激情区| 一级人做人爰a全过程免费视频 | 91av在线免费视频| 亚洲白色白色在线播放| 99热在线精品免费全部my| 成人区精品一区二区不卡亚洲| 韩日电影在线播放免费版| 日本三级2019在线观看免费| 国产亚洲精品a在线观看| 亚洲ts人妖网站| 国产羞羞的视频在线观看免费| 我要看WWW免费看插插视频| 亚洲AV永久无码精品放毛片| 又粗又硬免费毛片| 男女拍拍拍免费视频网站| 亚洲精品国产成人专区| 免费电影在线观看网站| 美女黄色免费网站| 亚洲一区AV无码少妇电影☆| 国产精品亚洲专区在线播放| 亚洲乱码中文字幕手机在线 | 亚洲精品国产首次亮相 | 一级毛片在播放免费| 亚洲AV无码专区电影在线观看| 免费看内射乌克兰女| 青青草国产免费久久久91 | 国产精品亚洲二区在线观看| 亚洲欧洲日韩极速播放| 日韩亚洲精品福利| 精品成人免费自拍视频| 亚洲日本在线电影| 在线jyzzjyzz免费视频| 国产精品亚洲综合五月天|