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

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

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

    posts - 33,  comments - 11,  trackbacks - 0

    該錯(cuò)誤集合中有些是我自己總結(jié)的,有些是從網(wǎng)絡(luò)上搜索到的別人的一些錯(cuò)誤處理集合,都放在一起來(lái)了

    0、 需要標(biāo)識(shí)符
    a) 不在函數(shù)內(nèi)
    1、 非法表達(dá)式開(kāi)始
    b) 可能:丟失括號(hào) .
    2. no data found
    a) 可能:setInt(1,100)中,沒(méi)有100這個(gè)值
    3. 找不到符號(hào)
    a) 可能:沒(méi)導(dǎo)入包
    4. 指定了無(wú)效URL
    a) 可能:數(shù)據(jù)庫(kù)名或IP錯(cuò)誤,即連接出錯(cuò)
    5. 類路徑?jīng)]有找到
    a) 可能: ClassNotFoundException: oracle.jdbc.driver.OracleDriver
    b) 原因: 一般是指包名寫錯(cuò),或者沒(méi)有import包,或者沒(méi)有在類路徑中找到j(luò)ar文件
    c) 解決: 沒(méi)有加載Oracle驅(qū)動(dòng)jar,在.bash_profile中把ojdbc14.jar加進(jìn)來(lái)
    6. 空指針異常
    a) 可能: 數(shù)據(jù)源錯(cuò)誤 比如數(shù)據(jù)庫(kù)名或IP錯(cuò)誤
    7. 不能執(zhí)行查詢
    a) 可能: 數(shù)據(jù)庫(kù)中表的問(wèn)題,比如列名不存在
    8. invalid identity
    a) 可能: 列名出錯(cuò)
    9. 若在數(shù)據(jù)庫(kù)中創(chuàng)建了 兩個(gè)sequence ,運(yùn)行時(shí)出現(xiàn)異常可能是先后執(zhí)行了多次select語(yǔ)句,導(dǎo)致與原有的序列號(hào)產(chǎn)生沖突
    10. 表名或列名不存在
    a) 可能:表不存在或者沒(méi)有插入數(shù)據(jù)到表中
    11. 不支持的類,類的版本錯(cuò)誤
    a) 可能:沒(méi)有導(dǎo)入jdk5.0,或者編譯器仍為1.4 
    12. MappingNotFoundException
    a) Maybe: In the Eclipse Not refersh , or not exist in the dirctory
    13. HibernateException: /hibernate.cfg.xml not found
    a) Maybe1: hibernate.cfg.xml not in the root directory
    b) Maybe2: Could not parse configuration .
    c) resolve: database not connect or use another database
    14. ConstraintViolationException
    a) Maybe: used a not true database
    15. 驅(qū)動(dòng)沒(méi)有找到 或者 JDBC Driver not found
    可能:連接數(shù)據(jù)庫(kù)的驅(qū)動(dòng)jar包不存在或者版本不一致,比如將舊的版本換成新的會(huì)造成該類錯(cuò)誤
    16. 空指針異常 , java.lang.NullPointerException 
    a) 可能1:數(shù)據(jù)庫(kù)連接出錯(cuò),比如在hibernate.cfg.xml中的數(shù)據(jù)錯(cuò)誤會(huì)導(dǎo)致異常。
    17. 數(shù)據(jù)插入異常 ,GenericJDBCException: could not insert 
    a) 可能1:沒(méi)有建立表或者表中沒(méi)有任何數(shù)據(jù)
    b) 可能2:插入數(shù)據(jù)后沒(méi)有執(zhí)行提交語(yǔ)句:commit
    18. LazyInitializationException 或者延遲加載異常
    a) 可能1:沒(méi)有在查詢語(yǔ)句中加fetch 
    19. IdentifierGenerationException
    a) 可能1:高位表沒(méi)有初始化(比如hi_value中沒(méi)有記錄) 
    20. could not initialize a collection: [hibernate.entity.Role.modules#32768] Syntax error: Encountered "-" at line 1, column 132.
    a) 錯(cuò)誤原因:<set name="modules" table="module-role" lazy="false">紅色字部分中“-”為非法字符,替換為module_role
    21. could not insert collection rows: [hibernate.entity.Module.roles#1]
     在Module.hbm.xml文件的如下配置中加入inverse=”true”
    <set name="roles" table="module_role" inverse="true">

    22.在部署Struts時(shí),出現(xiàn)如下錯(cuò)誤信息:
    HTTP Status 404 - Servlet action is not available
     
    type Status report
    message Servlet action is not available
    description The requested resource (Servlet action is not available) is not available.
    問(wèn)題原因:
    1.、web.xml文件中未配置ActionServlet。
    2、struts-config.xml文件未配置你要訪問(wèn)的Action。
    3、你的jsp文件form標(biāo)記中action屬性的路徑名稱錯(cuò)誤。
    4、非以上三種情況。
    針對(duì)以上4種情況相應(yīng)的解決方案如下:
    1、在web.xml文件中加上ActionServlet的配置信息
    ?????? /WEB-INF/struts-config.xml?
    ?2、在struts-config.xml文件檢查你要訪問(wèn)的Action配置文件。
    3、檢查jsp文件form標(biāo)記中action屬性的路徑名稱是否與struts-config.xml文件中action標(biāo)記的path屬性的路徑名稱一致。
    4、非以上情況的解決辦法就是檢查web容器的log日志,如果時(shí)tomcat則檢查下logs目錄下的localhost_log文件,看里邊是否記錄有錯(cuò)誤信息,然后根據(jù)錯(cuò)誤信息提示將其糾正。

    23.java.lang.NoClassDefFoundError: org/apache/commons/beanutils/Converter
    缺少spring-framework-2.0.3\lib\jakarta-commons\commons-beanutils.jar
    24.
    ava 代碼Caused by: java.lang.NoClassDefFoundError: org/objectweb/asm/Type  
    缺少spring-framework-2.0.3\lib\asm\asm-2.2.2.jar包,版本不同,該包的名字有相應(yīng)的區(qū)別

    java 代碼Caused by: java.lang.NoClassDefFoundError: org/dom4j/DocumentException  
    缺少spring-framework-2.0.3\lib\dom4j\dom4j-1.6.1.jar包,版本不同,該包的名字有相應(yīng)的區(qū)別
    把這個(gè)包進(jìn)去就可以了:\Spring206\lib\dom4j、dom4j-1.6.1.jar

    java 代碼Caused by: java.lang.NoClassDefFoundError: org/apache/commons/collections/SequencedHashMap  
    缺少spring-framework-2.0.3\lib\jakarta-commons\commons-collections.jar包,版本不同,該包的名字有相應(yīng)的區(qū)別

    java 代碼Caused by: java.lang.NoClassDefFoundError: net/sf/cglib/proxy/CallbackFilter  
    缺少spring-framework-2.0.3\lib\cglib\cglib-nodep-2.1_3.jar包,版本不同,該包的名字有相應(yīng)的區(qū)別

    java 代碼Caused by: java.lang.NoClassDefFoundError: org/objectweb/asm/CodeVisitor  
    缺少hibernate-3.2\lib\asm.jar包,版本不同,該包的名字有相應(yīng)的區(qū)別

    java 代碼
    org.hibernate.exception.SQLGrammarException: could not load an entity: [www.proudsoul.xml.User#1] 
    JAVA工程與WEB工程包的區(qū)別:一個(gè)是asm.jar,一個(gè)是jta.jar

    java 代碼Caused by: java.lang.NoClassDefFoundError: javax/transaction/TransactionManager  
    缺少spring-framework-2.0.3\lib\j2ee\jta.jar包,版本不同,該包的名字有相應(yīng)的區(qū)別此種錯(cuò)誤請(qǐng)檢查相應(yīng)的***.hbm.xml配置文件的配置

    25,
    Exception in thread "main" org.springframework.dao.InvalidDataAccessResourceUsageException: could not get next sequence value; nested exception is org.hibernate.exception.SQLGrammarException: could not get next sequence value
    Caused by: org.hibernate.exception.SQLGrammarException: could not get next sequence value
    原因:沒(méi)有加Sequence或者數(shù)據(jù)庫(kù)的方言寫錯(cuò)了

    26,
    我的配置文件
        <id name="id" column="id">
                <generator class="native" />
            </id>
    然后我運(yùn)行保存一條數(shù)據(jù)進(jìn)去
    The database returned no natively generated identity value
    就會(huì)報(bào)這個(gè)錯(cuò)誤
    因?yàn)槟鉵ative是根據(jù)看底層數(shù)據(jù)庫(kù)的能力選擇identity, sequence 或者h(yuǎn)ilo中的一個(gè)
    而我建表的時(shí)候id沒(méi)有指定
    alter table `student` change `id` `id` int auto_increment
    我們把我們的表的結(jié)構(gòu)小小的改動(dòng)一下就沒(méi)問(wèn)題了

    27,
    UpdateManager無(wú)法啟動(dòng)2007-08-09 15:21如果在應(yīng)用程序安裝過(guò)程中,暴力中斷安裝程序,會(huì)出現(xiàn)如下?tīng)顩r:1.apt-get remove 和dpkg --remove 無(wú)法刪除軟件 2.UpdateManager無(wú)法啟動(dòng)3.新立得軟件包管理程序無(wú)法啟動(dòng)
    以上可能是deb損壞之類造成的
    sudo dpkg -r sqldveloper
    正在讀取軟件包列表... 完成
    正在分析軟件包的依賴關(guān)系樹... 完成
    E: 軟件包 sqldeveloper 需要重新安裝,但是我無(wú)法找到相應(yīng)的安裝文件。
    解決方法:1.從 /var/lib/dpkg/status 中把對(duì)應(yīng)的段刪掉
    重要:修改之前請(qǐng)先備份
    在status中找到你對(duì)應(yīng)的包刪除就OK了...

    28,
    Exception in thread "main" java.lang.NoClassDefFoundError: antlr/ANTLRException
    少了antlr-2.7.5H3.jar包,從D:\eclipse\eclipse\plugins\com.genuitec.org.hibernate.eclipse_4.1.1\myeclipse-data\3.0\lib

    29,
    Caused by:
    java.lang.NoClassDefFoundError: javax/transaction/Synchronization
    缺少Spring206\lib\j2ee\jta.jar

    30,
    Caused by:
    java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy3] to required type [business.impl.PriceBiz] for property 'priceBiz': no matching editors or conversion strategy found
    在java類中設(shè)置priceBiz時(shí)應(yīng)該設(shè)置的是接口PriceBizIf,而非實(shí)現(xiàn)類

    18, 數(shù)組越界
     可能1: 在命令行后面需要加入?yún)?shù).
     可能2:加入的參數(shù)錯(cuò)誤
    19, car is not mapped
     可能1: 在cfg.xml中沒(méi)有增加映射的hbm.xml文件在<mapping.../>中   
    20, 屬性沒(méi)有找到
     可能1: hbm.xml文件中的 <property name =""> 有問(wèn)題, 也許是name的值與對(duì)應(yīng)類中的成員名不一致 
    21,SQLException: 無(wú)當(dāng)前連接          可能1:在比如創(chuàng)建帳戶時(shí)沒(méi)有對(duì)相應(yīng)的方法添加到<list>中去,比如這個(gè)沒(méi)有加入:<value>newAccount</value>
     
     <bean id="transactionAdvisor" class="org.springframework.aop.support.NameMatchMethodPointcutAdvisor">
      <property name="advice">
       <ref bean="advice"/>
      </property>
      <property name="mappedNames">
       <list>
        <value>transfer</value>
       </list>
     </bean>
    22,SQLException: Syntax error: Encountered "table" at line 1, column 8. 
     可能1;執(zhí)行SQL時(shí)出現(xiàn)沖突,可能是SQL語(yǔ)句中使用了關(guān)鍵字作為變量來(lái)用,比如
      update order set balance=1000000;
      其中order被用作表名來(lái)使用,這是錯(cuò)誤的,因?yàn)閛rder是個(gè)關(guān)鍵字,用在order by中

    23, Servlet /Spring-WebMvc threw load() exception
    org.xml.sax.SAXParseException: Document root element "beans", must match DOCTYPE root "null".
     jar包的沖突,spring-1.2.6.jar和spring.jar出現(xiàn)在一個(gè)war的目錄中:JBoss/server/all/deploy/Spring-WebMvc.war/WEB-INF/lib    

    24, java.sql.SQLException: 當(dāng)事務(wù)仍處于活動(dòng)狀態(tài)時(shí),無(wú)法關(guān)閉連接。 


    25 ,
    validateJarFile(/home/soft01/Tomcat/webapps/sms-token-struts/WEB-INF/lib/servlet-api.jar)
    Servlet /sms-struts-tiles threw load() exception
    java.lang.ClassNotFoundException: org.apache.struts.action.ActionServlet
    原因:在WEB-INF/lib/ 目錄下有servlet-api.jar與/Tomcat/common/lib目錄下的servlet-api.jar沖突了,把WEB-INF/lib/下的servlet-api.jar刪除就可以了

    26,java.lang.ClassNotFoundException: org.springframework.web.struts.ContextLoaderPlugIn
    Marking servlet action as unavailable
    10:30:47,088 ERROR [/NetCT_OSS]:3953 - Servlet /NetCT_OSS threw load() exception
    javax.servlet.UnavailableException

    27,org.xml.sax.SAXParseException: Document root element "beans", must match DOCTYPE root "null".
    缺少M(fèi)yEclipse/eclipse/plugins/com.genuitec.eclipse.springframework_5.5.0/data/2.0/dist/modules/spring-struts.jar

    28,Caused by: java.sql.BatchUpdateException: ORA-02291: integrity constraint (SD0702.FK82D343CF49A4B831) violated - parent key not found
    Caused by: org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
    有可能是ID生成策略的問(wèn)題,我將它XML映射文件改成<generator class="increment" />就好了

    29,
    2007-08-19 16:21:43,290 ERROR [org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/OSS].[action]] - Servlet.service() for servlet action threw exception
    org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [entity.Module#2]
    java.util.ConcurrentModificationException
    原因:已經(jīng)有對(duì)象擁有了所選擇的module,用clear(),而不是remove();

    30,
    ERROR [org.apache.catalina.session.ManagerBase] - IOException while loading persisted sessions: java.io.InvalidClassException: entity.Module; local class incompatible: stream classdesc serialVersionUID = -5988350031935445758, local class serialVersionUID = -297934247726484429
    java.io.InvalidClassException: entity.Module; local class incompatible: stream classdesc serialVersionUID = -5988350031935445758, local class serialVersionUID = -297934247726484429
    在Module中加上一個(gè)關(guān)鍵字:transient

    31,
    Caused by: java.sql.BatchUpdateException: ORA-02292: integrity constraint (SD0702.SYS_C00132664) violated - child record found
    原因:有其他的表引用了該表的外建,所以報(bào)這個(gè)異常,如果沒(méi)有引用就不會(huì)出現(xiàn)

    32,
    出現(xiàn)數(shù)組越界的時(shí)候,看看是不是循環(huán)時(shí)沒(méi)有加=,比如:
    for(int i = 1; i<arr.length;i++)可以改成
    for(int i = 1; i<=arr.length;i++)

     

    1.如果使用Ant和Junit是被報(bào)找不到test,檢查一下是否誤用了private
    出錯(cuò)信息:
        <failure message="No tests found in test.AllTest" type="junit.framework.AssertionFailedError">junit.framework.AssertionFailedError: No tests found in test.AllTest
    該錯(cuò)誤有個(gè)很特別的特點(diǎn),當(dāng)你不通過(guò)ant來(lái)運(yùn)行測(cè)試,而是通過(guò)AllTest類來(lái)運(yùn)行的話,可以正常運(yùn)行。小心哦

    2.如果遇到報(bào):表名無(wú)效,且jvm報(bào)嚴(yán)重錯(cuò)誤,看看是不是用了數(shù)據(jù)庫(kù)的保留關(guān)鍵字來(lái)做表名了,如User。

    3.使用ant時(shí)必須小心ant的classpath它用的不是IDE的classpath,小心!

    4.小心下邊的異常,
    exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of xp.bean.Users.?" type="net.sf.hibernate.PropertyAccessException">java.lang.ClassCastException at xp.bean.UsersMetaClass1.setPropertyValues(<generated>) at net.sf.hibernate.persister.AbstractEntityPersister.setPropertyValues
    上次出現(xiàn)該錯(cuò)錯(cuò)誤的原因是:
    源文件里我的class類型為一個(gè)類Contact contact
    而跑到mapping里卻成了Set,呵呵厲害。

    5.突然間冒出大量的NullPointException
    重新build一下看看先。

    6.="Flush during cascade is dangerous - this might occur if an object was deleted and then re-saved by cascade"

    7.Tapestry的出錯(cuò)信息:
    Class com.bookshop.Hello does not implement the IPage interface.
    location: context:/WEB-INF/Home.page, line 6
    原因:與顯示有關(guān)的哪個(gè)java類沒(méi)有從IPage家族繼承。

    8.使用ant時(shí)給出的路徑好象不允許出現(xiàn)空格。

    9.由于使用ant時(shí)用junit做測(cè)試的話,classpath中出現(xiàn)j2ee.jar的話,問(wèn)題多多。例如xml格式的log文件生成不了,莫名其妙的NullPointException等。所以我設(shè)置了兩個(gè)包個(gè)包含j2ee.jar,為編譯用;一個(gè)沒(méi)有,為junit用

    10.進(jìn)行單元測(cè)試時(shí),在查詢返回后應(yīng)馬上assertNotNull(),這樣可以更快速的定位NullPointException

    11.要使用ResourceBundle的話,要千萬(wàn)小心。必須用日志記錄下它的狀態(tài)。還有該屬性文件應(yīng)該放在classes下面。

    12.當(dāng)要顯示任何頁(yè)面時(shí),都被提示無(wú)效,那么應(yīng)該檢查一下lib目錄了,還有一些很奇怪的異常,例如你明明可以找到一個(gè)類但是服務(wù)器卻提示ClassNotDefException,那么估計(jì)是缺少了該類所必須的包了。或者多了不兼容的包,如, xdoclet系列包不被struts的lib目錄所兼容

    13.編寫clone時(shí)從Java編程思想(2nd)上學(xué)到的(732):
    .引數(shù)傳遞過(guò)程中會(huì)自動(dòng)產(chǎn)生別名(alias)。
    .沒(méi)有局域?qū)ο?local objects),只有局域性的(local)references。
    .reference受范圍(scope)的限制,對(duì)象則否。
    .對(duì)象的壽命從來(lái)不是Java的討論議題(因?yàn)橛欣厥諜C(jī)制)

    14.try catch finally的域居然是分離的。

    15.jsp亂碼的其中一個(gè)原因:charset="gb2312" 等號(hào)"="的兩邊不允許有空格。

    16.我的基于Displaytag的簡(jiǎn)單報(bào)表解決方案。
    http://displaytag.sourceforge.net/
    下載displaytag.jar和displaytag.tld
    displaytag.jar放在lib目錄,而displaytag.tld放在WEB-INF目錄,在web.xml中為displaytag.tld聲明一下。
      <taglib>
        <taglib-uri>http://displaytag.org</taglib-uri>
        <taglib-location>/WEB-INF/displaytag.tld</taglib-location>
      </taglib>
    在jsp里使用前,加上
      <%@ taglib uri="http://displaytag.org" prefix="display" %>
           
    注意該軟件有個(gè)bug,他要用的一個(gè)包c(diǎn)ommon-lang.jar版本必須在2.0以上。
    如果碰到下面異常,則應(yīng)堅(jiān)持一下是否該包的版本問(wèn)題。
    java.lang.NoSuchMethodError: org.apache.commons.lang.StringUtils.capitalize(Ljava/lang/String;)Ljava/lang/String;
    然后就可放心使用了
    <display:column property = "xxx"/>其中xxx為對(duì)象中的帶有g(shù)etter的變量>。
    定義表格的樣子,用css定義。如
    TABLE.its THEAD TR {
     BACKGROUND-COLOR: #69c
    }
    TABLE.its TR.even {
     BACKGROUND-COLOR: #def
    }
    在使用分頁(yè)時(shí),可能會(huì)出現(xiàn)這種情況,點(diǎn)擊其他頁(yè)時(shí),彈出下載窗口,讓你下載當(dāng)前jsp頁(yè)面,這是因?yàn)槟阍诋?dāng)前頁(yè)面讀取了數(shù)據(jù)的緣故。解決辦法為在action里讀取數(shù)據(jù)而不是在jsp里。可以參考
    http://www.displaytag.org/example-paging.jsp?d-26189-p=2

    17.使用displaytag時(shí),在一列中放入多個(gè)元素
    必須在display:table中定義一個(gè)id
    <display:table name = "allBooks" class = "its" pagesize = "5" id = "item">
      <display:column title = "操作">
        <a href = "/Bookshop/admin/bookManagement.do?action=view&id=<%=((Book)item).getId()%>" target = "_blank" >查看</a>
        <a href = "/Bookshop/admin/bookManagement.do?action=edit&id=<%=((Book)item).getId()%>">編輯</a>
        <a href = "/Bookshop/admin/bookManagement.do?action=delete&id=<%=((Book)item).getId()%>">刪除</a>
      </display:column>
    要在displaytag中使用鏈接,必須具備paramId,否則不顯示為鏈接
     <display:column property = "product.name" href = "viewDetailV2.0.jsp" title = "書名" paramId="item" paramProperty="product.id"/>
    可以這樣使用display
      <display:column property = "product.id" title = "ID"/>
    其中product為對(duì)象

    18.<bean:write name = "xxxx" property = "xxx"/> 可以直接取到session.getAttribute()取到的東西。

    19.實(shí)驗(yàn)struts-upload例子時(shí)要注意的地方:
       1.If you would rather write this file to another file, please check here:
     這一行要打鉤
       2.If you checked the box to write to a file, please specify the file path here:
    在這里要重命名如:c:\b.jpg
    上傳成功的話,會(huì)出現(xiàn)提示 The file has been written to "c:\b.jpg"

    20.Hibernate的like可以這么用:
          Query query = session.createQuery("from src.persistent.Book as book where upper(book.name) like :name ");
          query.setString("name", "%");
          result = query.list();

    21.Hibernate出現(xiàn) duplicate import : className
    異常也可能是因?yàn)橥藶槌志妙愒赾onfiguration中addClass了
         
    22.<logic:iterate id = "author" name = "authors">
    name所引用的是session里的attribute。

    23.如果發(fā)現(xiàn)要出現(xiàn)詢問(wèn)下載的情況,有可能是因?yàn)橐D(zhuǎn)的頁(yè)面出現(xiàn)了問(wèn)題。試試在要跳轉(zhuǎn)到的頁(yè)刪掉
    <%@ page contentType="text/html; charset=gb2312"%>

    24.如果JSP頁(yè)面跳轉(zhuǎn)時(shí)出現(xiàn)下邊的錯(cuò)誤信息:
    The request sent by the client was syntactically incorrect (Invalid path /web/shoppingCart was requested).
    原因是struts-config的action = "x" 寫成了 action = "x.do"

    25.在struts中,strut-config.xml中,forward時(shí)使用redirect = "true"可以將.do重定向?yàn)?jsp

    26.以后在判斷相等性之前先用logger把兩個(gè)值顯示出來(lái)。

    27.從session里getAttribute后,修改并不需要重新setAttribute一次。

    28.在hibernate中使用subclass是一棵繼承樹共用一個(gè)表,僅生成個(gè)mapping。
    每個(gè)類中必須有discrimator-value。在最上層的類中必須聲明:
    @hibernate.discriminator column = "class"。
    不可以將子類添加到configuration里去。(即不可addClass(子類))
    使用Xdoclet的建立subclass的例子(該類是父類)
    /**
     * @hibernate.class discriminator-value = "customer"
     * @hibernate.discriminator column = "class"
     */

    而使用joined-subclass則是一類一表,也不許將子類添加進(jìn)configuration里去。
    /**
     * @hibernate.joined-subclass
     * @hibernate.joined-subclass-key
     * column="customer_id"
     */
    如果發(fā)現(xiàn)生成的mapping文件中joined-subclass的key column為空,那么可能是@hibernate.joined-subclass-key這句沒(méi)有寫對(duì)。
    用joined-subclass生成的表,仔細(xì)看。Member extends Customer
    create table Customer (
       id VARCHAR2(255) not null,
       name VARCHAR2(255),
       description VARCHAR2(255),
       primary key (id)
    )
    create table Member (
       customer_id VARCHAR2(255) not null,
       password VARCHAR2(255),
       primary key (customer_id)
    )

    29.在junit中盡量使用assertEquals代替assertTrue;

    30.Hibernate
    如果Child extends Parent
    那么from Parent as parent 也將會(huì)將Child選出來(lái),而from Child as child 則不會(huì)選出Parent

    31.Hibernate
    使用hibernate的one-to-one時(shí),應(yīng)該兩方向都set,否則會(huì)報(bào)save NullPointException
    parent.setChild(child);
    child.setParent(parent);

    32.Hibernate
    遇到下邊的異常,估計(jì)是與因?yàn)橥怄I出現(xiàn)了問(wèn)題:

    java.lang.NullPointerException
     at net.sf.hibernate.persister.AbstractEntityPersister.getPropertyValue(AbstractEntityPersister.java:675)
     at net.sf.hibernate.id.ForeignGenerator.generate(ForeignGenerator.java:33)
    如:
    * @hibernate.id generator-class = "foreign"
    * @hibernate.generator-param name = "property" value = "customer"
    * @hibernate.one-to-one name = "custmoer" class = "src.persistent.Customer"
    value的值和one-to-one 中name的值不符,則會(huì)出現(xiàn)上邊的異常。如果不顯示指定name則默認(rèn)取成員變量名

    Customer a
    則name = "a" 需要小心的是不是類名。所以,以后最好顯示指定名字為好。

    33.出現(xiàn)異常:
    Exceptionobject references an unsaved transient instance - save the transient instance before flushing: src.persistent.Product
    原因沒(méi)有為某對(duì)象進(jìn)行set設(shè)置, 如上邊的這個(gè)就是某對(duì)象沒(méi)有調(diào)用setProduct

    34.
    "xxx action = "/a" 不用.do和根目錄名
    <a href = "b.do" 需要.do和根目錄名

    35.
    Caused by: java.sql.SQLException: ORA-02291: 違反完整約束條件 (BOOKSHOP.FK4AAEE
    47687CCA6B) - 未找到父項(xiàng)關(guān)鍵字
    如果你覺(jué)得該做的e是出現(xiàn)這個(gè)問(wèn)題,那么檢查一下,是否將類的繼承關(guān)系在hibernate的mapping中反映了出來(lái)。joined-subclass或subclass
    例如a extends b
    如果持久類c 需要Set的是持久類a,那么你把b傳入,而b又沒(méi)有在mapping中將父子關(guān)系反映出來(lái)的話,就會(huì)出現(xiàn)該異常

    36.使用DynaActionForm需要注意的問(wèn)題
    在struts-config聲明
    <form-bean name="memberloginForm" dynamic ="true" type="org.apache.struts.action.DynaActionForm">
      <form-property name = "name" type = "java.lang.String"/>
      <form-property name = "password" type = "java.lang.String"/>
    </form-bean>
    在Action里將form強(qiáng)制轉(zhuǎn)化成DynaActionForm,然后get("屬性名")就可以了

    37.那位大俠能給出一個(gè)用hibernate進(jìn)行分頁(yè)得實(shí)際例子,學(xué)習(xí)中!
    http://forum.hibernate.org.cn/viewtopic.php?t=1772
    Query q = s.find(".....");
    q.setFirstResult(10);   //  從第11條記錄開(kāi)始
    q.setMaxResults(100);  //  取出100條
    ......

    38.struts的validate最簡(jiǎn)單實(shí)現(xiàn)
    1.首先準(zhǔn)備好錯(cuò)誤提示信息。
    xxx.properties 里
    errors.required={0} is required.(默認(rèn)已有)
    2.Form必須從ValidatorForm繼承
    3.不可以重載ValidatorForm的validate函數(shù)
    4.在validate.xml中為你想驗(yàn)證的表單進(jìn)行驗(yàn)證設(shè)計(jì)。例如
    <form name="logonForm">
        <field property="userName" depends="required">
     <arg0 key="prompt.userName"/>
     (該參數(shù)將在顯示錯(cuò)誤信息是從xxx.properties讀取prompt.userName,填入{}方括號(hào)里,取代0。如果是arg1將將填入{1}位置,以此類推。
        </field>
    </form>
    不需要在action里做任何處理。只管forward就行了。作為forward的目標(biāo)頁(yè),不需要任何有關(guān)用于處理出錯(cuò)信息的處理。

    39.服務(wù)器報(bào)
    The requested resource (/xxxx/xxx.htm) is not available.的很奇怪的一個(gè)的可能原因
    在web.xml中定義的tld,沒(méi)有找到
    或者是lib目錄下的包太多出現(xiàn)了問(wèn)題。

      <taglib>
        <taglib-uri>/spring</taglib-uri>
        <taglib-location>/WEB-INF/spring.tld</taglib-location>
      </taglib>
    如WEB-INF目錄下不存在spring.tld的話,就會(huì)報(bào)上邊的錯(cuò)誤

    40.
    spring的xxx-servlet.xml的使用SimpleFormController系列的類問(wèn)題:
      <bean id = "priceIncreaseForm" class="PriceIncreaseFormController">
        <property name="sessionForm"><value>true</value></property>
        <property name="beanName"><value>priceIncrease</value></property>
        <property name="commandClass"><value>PriceIncrease</value></property>
        <property name="formView"><value>priceIncrease</value></property>
        <property name="successView"><value>hello</value></property>
        <property name="productManager">
          <ref bean="prodMan"/>
        </property>
      </bean>
    這里要注意幾個(gè)問(wèn)題:
    (1)上邊的PriceIncrease是了類名,必須在classes里存在該類,否則報(bào):
    PropertyVetoExceptionsException: 1 errors:-- ErrorCodedPropertyVetoException: message=[Failed to convert property value of type [java.lang.String] to required type [java.lang.Class] for property named 'commandClass'; nested exception is:
     java.lang.IllegalArgumentException: Invalid class name [PriceIncrease]: PriceIncrease]; errorCode=[typeMismatch]
    java.lang.IllegalArgumentException: Invalid class name [PriceIncrease]: PriceIncrease
    (2)<property name="formView"><value>priceIncrease</value></property>
    這一行必不可少,priceIncrease是頁(yè)面的名字,他將會(huì)是prefix + priceIncrease + suffix
    如果缺少該行,則報(bào):
    javax.servlet.ServletException: Error in ModelAndView object or View resolution encountered by servlet with name 'pocketSpring': View to render cannot be null with ModelAndView [ModelAndView: materialized View is [null]; Model=[{priceIncrease=PriceIncrease@148e798, org.springframework.validation.BindException.priceIncrease=org.springframework.validation.BindException: BindException: 0 errors}]]

    使用Errors的rejectValue相關(guān)問(wèn)題:
    rejectValue(java.lang.String field, java.lang.String errorCode, java.lang.Object[] errorArgs, java.lang.String defaultMessage)
    Reject the given field of the current object, using the given error description.
    當(dāng)前對(duì)象指的是xxx-servlet.xml中與validator類有聯(lián)系的哪個(gè)對(duì)象。
             
    第一個(gè)是:當(dāng)前對(duì)象的屬性名,必須存在
    第二個(gè)是:將要從屬性文件中讀取的消息
    第三個(gè)是:傳遞給所讀取的消息的參數(shù),如:
    error.too-low=You have to specify a percentage higher than {0}!
    第四個(gè)是:當(dāng)從屬性文件中讀取消息不成功時(shí),所reject的值

    以后從request中讀取parameter可以借用spring的RequestUtils包里的
    getStringParameter
    public static java.lang.String getStringParameter(javax.servlet.http.HttpServletRequest request,
                                               &bsp;      java.lang.String name,
                                                      java.lang.String defaultVal)
    Get a string parameter, with a fallback value. Never throws an exception. Can pass a distinguished value to default to enable checks of whether it was supplied.
    不會(huì)拋異常
    Hibernate的問(wèn)題:2.1rc的問(wèn)題
    INFO: cache provider: net.sf.ehcache.hibernate.Provider
    net.sf.hibernate.HibernateException: could not instantiate CacheProvider:
    解決辦法,2.1rc比以前的版本多需要一個(gè)包
    ehcache.jar

    43.static的問(wèn)題
    static函數(shù)只可以訪問(wèn)static成員變量。
    而static變量可以被任何成員函數(shù)訪問(wèn)。

    44.
    java.lang.NoClassDefFoundError: javax/transaction/Synchronization];
    需要添加JTA.jar

    posted on 2007-12-28 11:40 方濤升 閱讀(657) 評(píng)論(0)  編輯  收藏 所屬分類: j2ee
    <2007年12月>
    2526272829301
    2345678
    9101112131415
    16171819202122
    23242526272829
    303112345

    常用鏈接

    留言簿(2)

    隨筆分類

    隨筆檔案

    文章分類

    搜索

    •  

    最新評(píng)論

    閱讀排行榜

    評(píng)論排行榜

    主站蜘蛛池模板: 国产成人免费高清在线观看| 三年片在线观看免费观看大全动漫 | 久久亚洲精品国产精品婷婷| 玖玖在线免费视频| 亚洲人成亚洲人成在线观看 | 一个人看的免费高清视频日本| 国产乱人免费视频| 免费很黄无遮挡的视频毛片| 免费一区二区三区四区五区| 一区二区免费国产在线观看| 亚洲一区二区三区在线播放| 国产vA免费精品高清在线观看 | 一区二区在线免费观看| 91亚洲自偷手机在线观看| **aaaaa毛片免费| 久久精品国产亚洲av麻豆图片| 猫咪社区免费资源在线观看| 亚洲精品中文字幕| 大胆亚洲人体视频| 手机看片国产免费永久| 91亚洲国产成人久久精品网站| 亚洲精品免费网站| 亚洲精品无码成人片久久不卡| 亚洲Aⅴ无码一区二区二三区软件 亚洲AⅤ视频一区二区三区 | 亚洲综合男人的天堂色婷婷| 18禁成年无码免费网站无遮挡 | 日本免费电影一区二区| 亚洲国产成人精品久久 | 女同免费毛片在线播放| 亚洲狠狠ady亚洲精品大秀| 日本二区免费一片黄2019| 巨胸喷奶水www永久免费| 亚洲日韩在线视频| 四虎永久在线免费观看| 国产偷伦视频免费观看| 亚洲综合在线一区二区三区| 亚洲视频在线一区二区| 99久久99这里只有免费费精品| 青青视频免费在线| 亚洲激情在线视频| 国产成人精品123区免费视频|