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

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

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

    posts - 188,comments - 176,trackbacks - 0


    [轉]本篇文章包含了在用Struts開發web應用時經常碰到的一些異常和錯誤,根據異常或錯誤信息本身,經常可以找到潛在的錯誤發生原因。

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

    ******************************************************************

    Cannot retrieve mapping for action
     
    異常
    javax.servlet.jsp.JspException: Cannot retrieve mapping for action /Login (/Login是你的action名字) 
     
    可能原因 
    action沒有再struts-config.xml 中定義,或沒有找到匹配的action,例如在JSP文件中使用 ****************************************************************** 

    ******************************************************************

    Cannot retrieve definition for form bean null
     
    異常
    org.apache.jasper.JasperException: Cannot retrieve definition for form bean null
     
    可能原因       
    這個異常是因為Struts根據struts-config.xml中的mapping沒有找到action期望的form bean。大部分的情況可能是因為在form-bean中設置的name屬性和action中設置的name屬性不匹配所致。換句話說,action和form都應該各自有一個name屬性,并且要精確匹配,包括大小寫。這個錯誤當沒有name屬性和action關聯時也會發生,如果沒有在action中指定name屬性,那么就沒有name屬性和action相關聯。當然當action制作某些控制時,譬如根據參數值跳轉到相應的jsp頁面,而不是處理表單數據,這是就不用name屬性,這也是action的使用方法之一。
    ****************************************************************** 

    ******************************************************************

    No action instance for path /xxxx could be created

    可能原因
    特別提示:因為有很多中情況會導致這個錯誤的發生,所以推薦大家調高你的web服務器的日志/調試級別,這樣可以從更多的信息中看到潛在的、在試圖創建action類時發生的錯誤,這個action類你已經在struts-config.xml中設置了關聯(即添加了標簽)。
     
    在struts-config.xml中通過action標簽的class屬性指定的action類不能被找到有很多種原因,例如:定位編譯后的.class文件失敗。Failure to place compiled .class file for the action in the classpath (在web開發中,class的的位置在r WEB-INF/classes,所以你的action class必須要在這個目錄下。例如你的action類位于WEB-INF/classes/action/Login.class,那么在struts-config.xml中設置action的屬性type時就是action.Login). 拼寫錯誤,這個也時有發生,并且不易找到,特別注意第一個字母的大小寫和包的名稱。 

    在struts-config.xml中指定的action類沒有繼承自Stuts的Action類,或者你自定義的Action類沒有繼承自Struts提供的Action類。你的action類必須繼承自Struts提供的Action類。
     
    你的classpath的問題。例如web server沒有發現你的資源文件,資源文件必須在WEB-INF/classes/目錄下。
     
    Problem in struts-config.xml file with action mapping.
     
    Problem with data-sources.xml file.
     
    相關鏈接
    http://www.mail-archive.com/struts-user@jakarta.apache.org/msg65874.html
    Action Mapping mistake in struts-config.xml:
    http://www.manning.com/ao/readforum.html?forum=siaao&readthread=177
    data-sources.xml file?:
    http://www.caucho.com/quercus/faq/section.xtp?section_id=30
     

    ******************************************************************

    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中的某個變量定義getter 方法這個錯誤主要發生在表單提交的FormBean中,用struts標記時,在FormBean中必須有一個getUsername()方法。注意字母“U”。 

    Related Links
     Case can trip up the matching between get method's name and name specified in Struts tag
    http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=58&t=000163
    ****************************************************************** 

    ******************************************************************
    java.lang.NoClassDefFoundError: org/apache/struts/action/ActionForm
     
    錯誤
    java.lang.NoClassDefFoundError: org/apache/struts/action/ActionForm
     
    可能原因
    這個錯誤主要發生在在classpath中找不到相應的Java .class文件。如果這個錯誤發生在web應用程序的運行時,主要是因為指定的class文件不在web server的classpath中(/WEB-INF/classes 和 /WEB-INF/lib)。

    在上面的錯誤中,原因是找不到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.
     
    相關連接
     EJB and Web Shared Links:
    http://forum.java.sun.com/thread.jsp?forum=26&thread=413060&tstart=0&trange=15
    Keep Action and ActionForm (and their children) as non-overlapping unit(s) of an application
    http://www.mail-archive.com/struts-user@jakarta.apache.org/msg47466.html
    http://www.mail-archive.com/struts-user@jakarta.apache.org/msg47467.html
    ****************************************************************** 

     

    ******************************************************************
    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
     
    可能原因
    不是標識Struts actionServlet的標記就是映射.do擴展名的標記或者兩者都沒有在web.xml中聲明。 在struts-config.xml中的打字或者拼寫錯誤也可導致這個異常的發生。例如缺少一個標記的關閉符號/>。最好使用struts console工具檢查一下。
     
    另外,load-on-startup必須在web.xml中聲明,這要么是一個空標記,要么指定一個數值,這個數值用來表示servlet運行的優先級,數值越大優先級越低。
     
    還有一個和使用load-on-startup有關的是使用Struts預編譯JSP文件時也可能導致這個異常。
     
    相關鏈接
     Explicitly Define
    http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=50&t=001055
    http://threebit.net/tutorials/ejb/general/
     

    ******************************************************************
    NullPointerException at ... RequestUtils.forwardURL
     
    異常
    java.lang.NullPointerException at org.apache.struts.util.RequestUtils.forwardURL

    (RequestUtils.java:1223)
     
    可能原因
    在struts-config.xml中的forward元素缺少path屬性。例如應該是如下形式:

    ****************************************************************** 

    ******************************************************************

    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標記外使用form的子元素。這常常發生在你在后面使用Struts的html標記。

    另外要注意可能你不經意使用的無主體的標記,如,這樣web 服務器解析時就當作一個無主體的標記,隨后使用的所有標記都被認為是在這個標記之外的,如又使用了

    還有就是在使用taglib引入HTML標記庫時,你使用的prefix的值不是html。
     
    相關連接
     Using form subelements outside of a form tag
    http://forum.java.sun.com/thread.jsp?thread=337537&forum=4&message=1384153
    ****************************************************************** 

     

    ******************************************************************
    Missing message for key xx.xx.xx
     
    Exception
    javax.servlet.jsp.JspException: Missing message for key xx.xx.xx
     
    Probable Causes
    這個key的值對沒有在資源文件ApplicationResources.properties中定義。如果你使用eclipse時經常碰到這樣的情況,當項目重新編譯時,eclipse會自動將classes目錄下的資源文件刪除。 資源文件ApplicationResources.properties 不在classpath中 應將資源文件放到 WEB-INF/classes 目錄下,當然要在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
     
    可能原因
    很顯然,這個錯誤是發生在使用資源文件時,而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
     Provide Struts with Resource Bundle
    http://threebit.net/tutorials/ejb/general/
    XML Parser Issues
    http://www.mail-archive.com/struts-user@jakarta.apache.org/msg15779.html
    ****************************************************************** 

     

    ******************************************************************
    No input attribute for mapping path /loginAction
     
    錯誤
    No input attribute for mapping path /xxxxAction
     
    可能原因
    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
     
    錯誤
    Strange and seemingly random characters in HTML and on screen, but not in original JSP or

    servlet.
     
    可能原因
    混和使用Struts的html:form標記和標準的HTML標記不正確。使用的編碼樣式在本頁中不支持。
    ****************************************************************** 

    ******************************************************************

    "Document contained no data" or no data rendered on page
     
    錯誤
    "Document contained no data" in Netscape
     
    No data rendered (completely empty) page in Microsoft Internet Explorer
     
    可能原因
    使用一個Action的派生類而沒有實現perform()方法或execute()方法。在Struts1.0中實現的是perform()方法,在Struts1.1中實現的是execute()方法,但Struts1.1向后兼容perform()方法。

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


    轉CSDN
    posted on 2007-05-24 11:31 cheng 閱讀(319) 評論(0)  編輯  收藏 所屬分類: Struts
    主站蜘蛛池模板: 久久亚洲sm情趣捆绑调教| 国产成人+综合亚洲+天堂| 在线免费观看视频你懂的| 日韩亚洲综合精品国产| 亚洲精品无码mv在线观看网站| 最好看的中文字幕2019免费| 亚洲精华国产精华精华液| 精品久久久久久亚洲| 韩国免费一级成人毛片| 一级特黄a大片免费| 亚洲欧洲春色校园另类小说| 免费播放春色aⅴ视频| 6080午夜一级毛片免费看| 猫咪免费观看人成网站在线| 亚洲电影在线免费观看| 亚洲黄片毛片在线观看| 在线观看AV片永久免费| 99精品视频免费| 国产精品国产亚洲区艳妇糸列短篇 | 亚洲中文字幕一二三四区| 亚洲精品无码国产| 国产精品免费视频播放器| 一级成人a毛片免费播放| 曰韩无码AV片免费播放不卡 | 香蕉免费看一区二区三区| 色噜噜亚洲男人的天堂| 亚洲AV综合色一区二区三区| 国产精品成人无码免费| 日日麻批免费40分钟日本的| 99久久免费国产精品热| 日韩亚洲综合精品国产| 中中文字幕亚洲无线码| 久久亚洲AV成人无码电影| 国产成人综合亚洲亚洲国产第一页 | 青青草97国产精品免费观看| 亚洲а∨天堂久久精品9966| 久久久婷婷五月亚洲97号色| 亚洲综合熟女久久久30p| 亚洲国产精品日韩| 日本免费人成黄页在线观看视频| 国产一卡二卡3卡四卡免费|