No pains, No gain
          走過、路過、千萬別錯過
          posts - 23,comments - 1,trackbacks - 0

          理解ORACLE數(shù)據(jù)庫字符集

          一.引言

          ??? ORACLE數(shù)據(jù)庫字符集,即Oracle全球化支持(Globalization Support),或即國家語言支持(NLS)其作用是用本國語言和格式來存儲、處理和檢索數(shù)據(jù)。利用全球化支持,ORACLE為用戶提供自己熟悉的數(shù)據(jù)庫母語環(huán)境,諸如日期格式、數(shù)字格式和存儲序列等。Oracle可以支持多種語言及字符集,其中oracle8i支持48種語言、76個國家地域、229種字符集,而oracle9i則支持57種語言、88個國家地域、235種字符集。由于oracle字符集種類多,且在存儲、檢索、遷移oracle數(shù)據(jù)時多個環(huán)節(jié)與字符集的設(shè)置密切相關(guān),因此在實際的應(yīng)用中,數(shù)據(jù)庫開發(fā)和管理人員經(jīng)常會遇到有關(guān)oracle字符集方面的問題。本文通過以下幾個方面闡述,對oracle字符集做簡要分析

          二.字符集基本知識

          2.1字符集
          ??? 實質(zhì)就是按照一定的字符編碼方案,對一組特定的符號,分別賦予不同數(shù)值編碼的集合。Oracle數(shù)據(jù)庫最早支持的編碼方案是US7ASCII。
          ??? Oracle
          的字符集命名遵循以下命名規(guī)則 :
          ???
          ???
          :? <語言><比特位數(shù)><編碼
          >
          ???
          比如: ZHS16GBK表示采用GBK編碼格式、16位(兩個字節(jié))簡體中文字符集

          2.2字符編碼方案
          2.2.1 單字節(jié)編碼
          ???
          1)單字節(jié)7位字符集,可以定義128個字符,最常用的字符集為 US7ASCII
          ???
          2)單字節(jié)8位字符集,可以定義256個字符,適合于歐洲大部分國家

          ???
          例如:WE8ISO8859P1(西歐、8位、ISO標(biāo)準(zhǔn)8859P1編碼 )
          2.2.2
          多字節(jié)編碼

          ???
          1)變長多字節(jié)編碼
          ????
          某些字符用一個字節(jié)表示,其它字符用兩個或多個字符表示,變長多字節(jié)編碼常用于對亞洲語言的支持,?? 例如日語、漢語、印地語等
          ???
          例如:AL32UTF8(其中AL代表ALL,指適用于所有語言)、 zhs16cgb231280
          ???
          2)定長多字節(jié)編碼

          ???
          每一個字符都使用固定長度字節(jié)的編碼方案,目前oracle唯一支持的定長多字節(jié)編碼是AF16UTF16,也是僅用于國家字符集
          2.2.3 unicode
          編碼
          ??? Unicode
          是一個涵蓋了目前全世界使用的所有已知字符的單一編碼方案,也就是說Unicode為每一個字符提供唯一的編碼。UTF-16unicode16位編碼方式,是一種定長多字節(jié)編碼,用2個字節(jié)表示一個unicode字符,AF16UTF16UTF-16編碼字符集。
          ??? UTF-8
          unicode8位編碼方式,是一種變長多字節(jié)編碼,這種編碼可以用1、2、3個字節(jié)表示一個unicode字符,AL32UTF8,UTF8、UTFEUTF-8編碼字符集

          2.3 字符集超級
          ??? 當(dāng)一種字符集(字符集A)的編碼數(shù)值包含所有另一種字符集(字符集B)的編碼數(shù)值,并且兩種字符集相同編碼數(shù)值代表相同的字符時,則字符集A是字符集B的超級,或稱字符集B是字符集A的子集。
          ??? Oracle8i
          oracle9i官方文檔資料中備有子集-超級對照表(subset-superset pairs),例如:WE8ISO8859P1WE8MSWIN1252的子集。由于US7ASCII是最早的Oracle數(shù)據(jù)庫編碼格式,因此有許多字符集是US7ASCII的超集,例如WE8ISO8859P1、ZHS16CGB231280、ZHS16GBK都是US7ASCII的超集。

          2.4 數(shù)據(jù)庫字符集(oracle服務(wù)器端字符集)
          ??? 數(shù)據(jù)庫字符集在創(chuàng)建數(shù)據(jù)庫時指定,在創(chuàng)建后通常不能更改。在創(chuàng)建數(shù)據(jù)庫時,可以指定字符集(CHARACTER SET)和國家字符集(NATIONAL CHARACTER SET)。
          2.4.1
          字符集
          ??? (1)
          用來存儲CHAR, VARCHAR2, CLOB, LONG等類型數(shù)據(jù)
          ??? (2)
          用來標(biāo)示諸如表名、列名以及PL/SQL變量等
          ??? (3)
          用來存儲SQLPL/SQL程序單元等
          2.4.2
          國家字符集:
          ??? (1)
          用以存儲NCHAR, NVARCHAR2, NCLOB等類型數(shù)據(jù)
          ??? (2)
          國家字符集實質(zhì)上是為oracle選擇的附加字符集,主要作用是為了增強(qiáng)oracle的字符處理能力,因為NCHAR數(shù)據(jù)類型可以提供對亞洲使用定長多字節(jié)編碼的支持,而數(shù)據(jù)庫字符集則不能。國家字符集在oracle9i中進(jìn)行了重新定義,只能在unicode編碼中的AF16UTF16UTF8中選擇,默認(rèn)值是 AF16UTF16
          2.4.3
          查詢字符集參數(shù)

          ???
          可以查詢以下數(shù)據(jù)字典或視圖查看字符集設(shè)置情況
          ??? nls_database_parameters
          props$、 v$nls_parameters
          ???
          查詢結(jié)果中NLS_CHARACTERSET表示字符集,NLS_NCHAR_CHARACTERSET表示國家字符集

          2.4.4
          修改數(shù)據(jù)庫字符集
          ???
          按照上文所說,數(shù)據(jù)庫字符集在創(chuàng)建后原則上不能更改。如果需要修改字符集,通常需要導(dǎo)出數(shù)據(jù)庫數(shù)據(jù),重建數(shù)據(jù)庫,再導(dǎo)入數(shù)據(jù)庫數(shù)據(jù)的方式來轉(zhuǎn)換,或通過ALTER DATABASE CHARACTER SET語句修改字符集,但創(chuàng)建數(shù)據(jù)庫后修改字符集是有限制的,只有新的字符集是當(dāng)前字符集的超集時才能修改數(shù)據(jù)庫字符集,例如UTF8US7ASCII的超集,修改數(shù)據(jù)庫字符集可使用ALTER DATABASE CHARACTER SET UTF8。

          2.5 客戶端字符集(NLS_LANG參數(shù))
          2.5.1
          客戶端字符集含義
          ???
          客戶端字符集定義了客戶端字符數(shù)據(jù)的編碼方式,任何發(fā)自或發(fā)往客戶端的字符數(shù)據(jù)均使用客戶端定義的字符集編碼,客戶端可以看作是能與數(shù)據(jù)庫直接連接的各種應(yīng)用,例如sqlplus,exp/imp等。客戶端字符集是通過設(shè)置NLS_LANG參數(shù)來設(shè)定的。
          2.5.2 NLS_LANG
          參數(shù)格式
          ??? NLS_LANG=_.
          ??? Language:
          顯示oracle消息,校驗,日期命名
          ??? Territory
          :指定默認(rèn)日期、數(shù)字、貨幣等格式
          ??? Client character set
          :指定客戶端將使用的字符集
          ???
          例如: NLS_LANG=AMERICAN_AMERICA.US7ASCII?
          ??? AMERICAN
          是語言,AMERICA是地區(qū),US7ASCII是客戶端字符集

          2.5.3
          客戶端字符集設(shè)置方法
          ???? 1)UNIX
          環(huán)境
          ???????? $NLS_LANG=“simplified chinese”_china.zhs16gbk
          ???????? $export NLS_LANG
          ????????
          編輯oracle用戶的profile文件
          ??? 2)Windows
          環(huán)境
          ????????
          編輯注冊表
          ???????? Regedit.exe---HKEY_LOCAL_MACHINE---SOFTWARE---ORACLE—HOME0
          2.5.4 NLS
          參數(shù)查詢
          ??? Oracle
          提供若干NLS參數(shù)定制數(shù)據(jù)庫和用戶機(jī)以適應(yīng)本地格式,例如有NLS_LANGUAGE,NLS_DATE_FORMAT,NLS_CALENDER等,可以通過查詢以下數(shù)據(jù)字典或v$視圖查看。
          ??? NLS_DATABASE_PARAMETERS--
          顯示數(shù)據(jù)庫當(dāng)前NLS參數(shù)取值,包括數(shù)據(jù)庫字符集取值
          ??? NLS_SESSION_PARAMETERS--
          顯示由NLS_LANG 設(shè)置的參數(shù),或經(jīng)過alter session 改變后的參數(shù)值(不包括由NLS_LANG 設(shè)置的客戶端字符集)
          ??? NLS_INSTANCE_PARAMETE--
          顯示由參數(shù)文件init.ora 定義的參數(shù)V$NLS_PARAMETERS--顯示數(shù)據(jù)庫當(dāng)前NLS參數(shù)取值
          2.5.5
          修改NLS參數(shù)
          ???
          使用下列方法可以修改NLS參數(shù)
          ???
          1)修改實例啟動時使用的初始化參數(shù)文件
          ???
          2)修改環(huán)境變量 NLS_LANG
          ???
          3)使用ALTER SESSION語句,在oracle會話中修改

          ???
          4)使用某些SQL函數(shù)
          ??? NLS
          作用優(yōu)先級別:Sql function>alter session>環(huán)境變量或注冊表>參數(shù)文件>數(shù)據(jù)庫默認(rèn)參數(shù)

          三.導(dǎo)入/導(dǎo)出與字符集轉(zhuǎn)換

          3.1 EXP/IMP
          ??? Export Import 是一對讀寫Oracle數(shù)據(jù)的工具。Export Oracle 數(shù)據(jù)庫中的數(shù)據(jù)輸出到操作系統(tǒng)文件中, Import 把這些文件中的數(shù)據(jù)讀到Oracle 數(shù)據(jù)庫中,由于使用exp/imp進(jìn)行數(shù)據(jù)遷移時,數(shù)據(jù)從源數(shù)據(jù)庫到目標(biāo)數(shù)據(jù)庫的過程中有四個環(huán)節(jié)涉及到字符集,如果這四個環(huán)節(jié)的字符集不一致,將會發(fā)生字符集轉(zhuǎn)換。

          EXP
          ???? ____________? ?_________________? _____________
          ???? |imp導(dǎo)入文件|<-><->
          ?????------------?? -----------------??-------------

          IMP?
          ???? ____________? ?_________________? _____________
          ???? |imp導(dǎo)入文件|->|環(huán)境變量NLS_LANG|->|數(shù)據(jù)庫字符集|
          ?????------------?? -----------------??-------------

          ??? 四個字符集是
          ??
          1)源數(shù)據(jù)庫字符集
          ??
          2Export過程中用戶會話字符集(通過NLS_LANG設(shè)定)
          ??
          3Import過程中用戶會話字符集(通過NLS_LANG設(shè)定)
          ??
          4)目標(biāo)數(shù)據(jù)庫字符集

          3.2導(dǎo)出的轉(zhuǎn)換過程
          ??? Export過程中,如果源數(shù)據(jù)庫字符集與Export用戶會話字符集不一致,會發(fā)生字符集轉(zhuǎn)換,并在導(dǎo)出文件的頭部幾個字節(jié)中存儲Export用戶會話字符集的ID號。在這個轉(zhuǎn)換過程中可能發(fā)生數(shù)據(jù)的丟失。
          :如果源數(shù)據(jù)庫使用ZHS16GBK,而Export用戶會話字符集使用US7ASCII,由于ZHS16GBK16位字符集,US7ASCII7位字符集,這個轉(zhuǎn)換過程中,中文字符在US7ASCII中不能夠找到對等的字符,所以所有中文字符都會丟失而變成“?? ”形式,這樣轉(zhuǎn)換后生成的Dmp文件已經(jīng)發(fā)生了數(shù)據(jù)丟失。
          因此如果想正確導(dǎo)出源數(shù)據(jù)庫數(shù)據(jù),則Export過程中用戶會話字符集應(yīng)等于源數(shù)據(jù)庫字符集或是源數(shù)據(jù)庫字符集的超集

          3.3導(dǎo)入的轉(zhuǎn)換過程
          ???
          1)確定導(dǎo)出數(shù)據(jù)庫字符集環(huán)境
          ???
          通過讀取導(dǎo)出文件頭,可以獲得導(dǎo)出文件的字符集設(shè)置
          ???
          2)確定導(dǎo)入session的字符集,即導(dǎo)入Session使用的NLS_LANG環(huán)境變量
          ???
          3IMP讀取導(dǎo)出文件
          ???
          讀取導(dǎo)出文件字符集ID,和導(dǎo)入進(jìn)程的NLS_LANG進(jìn)行比較
          ???
          4)如果導(dǎo)出文件字符集和導(dǎo)入Session字符集相同,那么在這一步驟內(nèi)就不需要轉(zhuǎn)換,如果不同,就需要把數(shù)據(jù)轉(zhuǎn)換為導(dǎo)入Session使用的字符集??梢钥闯?,導(dǎo)入數(shù)據(jù)到數(shù)據(jù)庫過程中發(fā)生兩次字符集轉(zhuǎn)換
          ???
          第一次:導(dǎo)入文件字符集與導(dǎo)入Session使用的字符集之間的轉(zhuǎn)換,如果這個轉(zhuǎn)換過程不能正確完成,Import向目標(biāo)數(shù)據(jù)庫的導(dǎo)入過程也就不能完成。
          ???
          第二次:導(dǎo)入Session字符集與數(shù)據(jù)庫字符集之間的轉(zhuǎn)換。
          ???
          然而,oracle8i的這種轉(zhuǎn)換只能在單字節(jié)字符集之間進(jìn)行,oracle8i導(dǎo)入Session不支持多字節(jié)字符集之間的轉(zhuǎn)換,因此為了避免第一次轉(zhuǎn)換,導(dǎo)入Session使用的NLS_LANG與導(dǎo)出文件字符集相同,第二次轉(zhuǎn)換(通過SQL*Net)支持任何兩種字符集。以上情況在Oracle9i中略有不同

          四.亂碼問題

          ??? oracle在數(shù)據(jù)存儲、遷移過程中經(jīng)常發(fā)生字符亂碼問題,歸根到底是由于字符集使用不當(dāng)引起。下面以使用客戶端sqlplus向數(shù)據(jù)庫插入數(shù)據(jù)和導(dǎo)入/導(dǎo)出(EXP/IMP)過程為例,說明亂碼產(chǎn)生的原因。

          4.1使用客戶端sqlplus向數(shù)據(jù)庫存儲數(shù)據(jù)
          ???
          這個過程存在3個字符集設(shè)置
          ???
          1)客戶端應(yīng)用字符集
          ???
          2)客戶端NLS_LANG參數(shù)設(shè)置
          ???
          3)服務(wù)器端數(shù)據(jù)庫字符集(Character Set)設(shè)置
          ???
          客戶端應(yīng)用sqlplus中能夠顯示什么樣的字符取決于客戶端操作系統(tǒng)語言環(huán)境(客戶端應(yīng)用字符集),但在應(yīng)用中錄入這些字符后,這些字符能否在數(shù)據(jù)庫中正常存儲,還與另外兩個字符集設(shè)置緊密相關(guān),其中客戶端NLS_LANG參數(shù)主要用于字符數(shù)據(jù)傳輸過程中的轉(zhuǎn)換判斷。常見的亂碼大致有兩種情形:
          ???
          1)漢字變成問號?
          當(dāng)從字符集A 轉(zhuǎn)換成字符集B時,如果轉(zhuǎn)換字符之間不存在對應(yīng)關(guān)系,NLS_LANG使用替代字符?替代無法映射的字符
          ???
          2)漢字變成未知字符(雖然有些是漢字,但與原字符含義不同)
          轉(zhuǎn)換存在對應(yīng)關(guān)系,但字符集A 中的字符編碼與字符集B 中的字符編碼代表不同含義

          4.2發(fā)生亂碼原因 ?
          ?? ?
          亂碼產(chǎn)生是由于幾個字符集之間轉(zhuǎn)換不匹配造成,分以下幾種情況:

          ???
          (注:字符集之間如果不存在子集、超集對應(yīng)關(guān)系時的情況不予考慮,因為這種情況下字符集之間轉(zhuǎn)換必產(chǎn)生亂碼) ???
          ??? 1
          )服務(wù)器端數(shù)據(jù)庫字符集與客戶端應(yīng)用字符集相同,與客戶端NLS_LANG參數(shù)設(shè)置不同

          ???
          如果客戶端NLS_LANG字符集是其它兩種字符集的子集,轉(zhuǎn)換過程將出現(xiàn)亂碼。
          ???
          解決方法:將三種字符集設(shè)置成同一字符集,或NLS_LANG字符集是其它兩種字符集的超集
          ??? 2
          )服務(wù)器端數(shù)據(jù)庫字符集與客戶端NLS_LANG參數(shù)設(shè)置相同,與客戶端應(yīng)用字符集不同
          ???
          如果客戶端應(yīng)用字符集是其它兩種字符集的超集時,轉(zhuǎn)換過程將出現(xiàn)亂碼,但對于單字節(jié)編碼存儲中文問題,可參看本文第5章節(jié)的分析
          ??? 3
          )客戶端應(yīng)用字符集、客戶端NLS_LANG參數(shù)設(shè)置、服務(wù)器端數(shù)據(jù)庫字符集互不相同
          ?? ?
          此種情況較為復(fù)雜,但三種字符集之間只要有不能轉(zhuǎn)換的字符,則必產(chǎn)生亂碼

          4.3導(dǎo)入/導(dǎo)出過程出現(xiàn)亂碼原因
          ???
          這個過程存在4個字符集設(shè)置,在3.1章節(jié)中已分析
          ??
          1)源數(shù)據(jù)庫字符集
          ??
          2EXP過程中NLS_LANG參數(shù)
          ??
          3IMP過程中NLS_LANG參數(shù)
          ??
          4)目標(biāo)數(shù)據(jù)庫字符集
          ???
          出現(xiàn)亂碼原因
          ??? 1
          )當(dāng)源數(shù)據(jù)庫字符集不等于EXP過程中NLS_LANG參數(shù),且源數(shù)據(jù)庫字符集是EXP過程中NLS_LANG的子集,才能保證導(dǎo)出文件正確,其他情況則導(dǎo)出文件字符亂碼
          ??? 2
          EXP過程中NLS_LANG字符集不等于IMP過程中NLS_LANG字符集,且EXP過程中NLS_LANG字符集是IMP過程中NLS_LANG字符集的子級, 才能保證第一次轉(zhuǎn)換正常,否則第一次轉(zhuǎn)換中出現(xiàn)亂碼。
          ??? 3
          )如果第一次轉(zhuǎn)換正常,IMP過程中NLS_LANG字符集是目標(biāo)數(shù)據(jù)庫字符集的子集或相同,才能保證第二次轉(zhuǎn)換正常,否則則第二次轉(zhuǎn)換中出現(xiàn)亂碼

          五.單字節(jié)編碼存儲中文問題

          ??? 由于歷史的原因,早期的oracle沒有中文字符集(如oracle6、oracle7oracle7.1,但有的用戶從那時起就使用數(shù)據(jù)庫了,并用US7ASCII字符集存儲了中文,或是有的用戶在創(chuàng)建數(shù)據(jù)庫時,不考慮清楚,隨意選擇一個默認(rèn)的字符集,如WE8ISO8859P1US7ASCII,而這兩個字符集都沒有漢字編碼,雖然有些時候選用這種字符集好象也能正常使用,但用這種字符集存儲漢字信息從原則上說就是錯誤的,它會給數(shù)據(jù)庫的使用與維護(hù)帶來一系列的麻煩。
          ???
          正常情況下,要將漢字存入數(shù)據(jù)庫,數(shù)據(jù)庫字符集必須支持中文,而將數(shù)據(jù)庫字符集設(shè)置為US7ASCII等單字節(jié)字符集是不合適的。US7ASCII字符集只定義了128個符號,并不支持漢字。另外,如果在SQL*PLUS中能夠輸入中文,操作系統(tǒng)缺省應(yīng)該是支持中文的,但如果在NLS_LANG中的字符集設(shè)置為US7ASCII,顯然也是不正確的,它沒有反映客戶端的實際情況。但在實際應(yīng)用中漢字顯示卻是正確的,這主要是因為Oracle檢查數(shù)據(jù)庫與客戶端的字符集設(shè)置是同樣的,那么數(shù)據(jù)在客戶與數(shù)據(jù)庫之間的存取過程中將不發(fā)生任何轉(zhuǎn)換,但是這實際上導(dǎo)致了數(shù)據(jù)庫標(biāo)識的字符集與實際存入的內(nèi)容是不相符的。而在SELECT的過程中,Oracle同樣檢查發(fā)現(xiàn)數(shù)據(jù)庫與客戶端的字符集設(shè)置是相同的,所以它也將存入的內(nèi)容原封不動地傳送到客戶端,而客戶端操作系統(tǒng)識別出這是漢字編碼所以能夠正確顯示。
          ???
          在這個例子中,數(shù)據(jù)庫與客戶端都沒有設(shè)置成中文字符集,但卻能正常顯示中文,從應(yīng)用的角度看好象沒問題。然而這里面卻存在著極大的隱患,比如在應(yīng)用lengthsubstr等字符串函數(shù)時,就可能得到意外的結(jié)果。
          ???
          對于早期使用US7ASCII字符集數(shù)據(jù)庫的數(shù)據(jù)遷移到oracle8i/9i中(使用zhs16gbk),由于原始數(shù)據(jù)已經(jīng)按照US7ASCII格式存儲,對于這種情況,可以通過使用Oracle8i的導(dǎo)出工具,設(shè)置導(dǎo)出字符集為US7ASCII,導(dǎo)出后使用UltraEdit等工具打開dmp文件,修改第二、三字符,修改 0001 0354,這樣就可以將US7ASCII字符集的數(shù)據(jù)正確導(dǎo)入到ZHS16GBK的數(shù)據(jù)庫中。

          六.結(jié)束語

          ??? 為了避免在數(shù)據(jù)庫遷移過程中由于字符集不同導(dǎo)致的數(shù)據(jù)損失,oracle提供了字符集掃描工具(character set scanner),通過這個工具我們可以測試在數(shù)據(jù)遷移過程中由于字符集轉(zhuǎn)換可能帶來的問題,然后根據(jù)測試結(jié)果,確定數(shù)據(jù)遷移過程中最佳字符集解決方案。


          參考文獻(xiàn)
          [1]Biju Thomas , Bob Bryla
          oracle9i DBA基礎(chǔ)I 學(xué)習(xí)指南》電子工業(yè)出版社 2002

          posted @ 2007-02-13 13:12 一縷青煙 閱讀(219) | 評論 (0)編輯 收藏

          表格部分代碼如下:

          <table id="testTbl" border=1>

          <tr id="tr1">

          <td width=6%><input type=checkbox id="box1"></td>

          <td id="b">第一行</td>

          </tr>

          <tr id="tr2">

          <td width=6%><input type=checkbox id="box2"></td>

          <td id="b">第二行</td>

          </tr>

          <tr>

          <td width=6%><input type=checkbox id="box3"></td>

          <td>第三行</td>

          </tr>

          </table>

          動態(tài)添加表行的javascript函數(shù)如下:

          <script language="javascript">

          function addRow(){

          //添加一行

          var newTr = testTbl.insertRow();

          //設(shè)置行背景

          newTr.bgColor = '#008040';

          //添加兩列

          var newTd0 = newTr.insertCell();

          var newTd1 = newTr.insertCell();

          //設(shè)置列內(nèi)容和屬性

          newTd0.innerHTML = '<input type=checkbox id="box4">';

          newTd1.innerText= '新增加的行';
          }
          </script>

          <BR>
          <a href="#" onclick="addRow();">增加一行</a>


          就這么簡單,做點(diǎn)詳細(xì)的說明:

          1、inserRow()和insertCell()函數(shù)

          insertRow()函數(shù)可以帶參數(shù),形式如下:

          insertRow(index)

          這個函數(shù)將新行添加到index的那一行前,比如insertRow(0),是將新行添加到第一行之前。默認(rèn)的insertRow()函數(shù)相當(dāng)于insertRow(-1),將新行添加到表的最后。

          insertCell()和insertRow的用法相同。

          2、動態(tài)設(shè)置屬性和事件

          上面行數(shù)中的innerHTML和innerText都是列的屬性。

          這個inner,就是“inner”到<tb></tb>之間,innerText是添加到<tb></tb>之間的文本,innerHTML是添加到<tb></tb>之間的HTML代碼(這個so簡單,這個解釋挺多余的)

          設(shè)置其他屬性也是用同樣的方式,比如,設(shè)置行背景色

          newTr.bgColor = 'red';

          ?

          設(shè)置事件也一樣,需要簡單說明一點(diǎn)。

          比如,我要讓點(diǎn)擊新加行的時候執(zhí)行一個自己定義的函數(shù) newClick,newClick行數(shù)如下:

          function newClick(){

          alert("這是新添加的行");

          對onclick事件設(shè)置這個函數(shù)的代碼如下:

          newTr.onclick = newClick;

          這里需要主義的是,=后面的部分必須是函數(shù)名,而且不能帶引號,

          newTr.onclick = newClick();

          newTr.onclick = 'newClick';

          newTr.onclick = "newClick";

          上面的寫法都是錯誤的。

          為什么,其實知道為什么沒有什么意思,知道怎么用就OK了,如果不想知道,可以跳過下面這一段。

          ?

          實際上這個=后面的newClick是指向自己定義的newClick函數(shù)的指針,javascript里面函數(shù)名就是指向函數(shù)的指針,加了引號括號什么的瀏覽器就找不到那個函數(shù)了。

          下面的寫法,也是正確的

          newTr.onclick = function newClick(){

          alert("這是新添加的行");

          這個使用函數(shù)名實際上是一樣的

          設(shè)置其他的事件用法相同。

          posted @ 2007-01-18 14:39 一縷青煙 閱讀(1818) | 評論 (0)編輯 收藏
          J2EE程序中使用oracle數(shù)據(jù)庫LOB字段的總結(jié)(elathen)
          ???http://www.souzz.net 2005-10-23 文章出處:博客園
          ?
          ????

          posted on 2005-05-27 09:36 輕松逍遙子

          最近在J2EE的項目中需要使用LOB字段保存文本信息以及圖片和文件,到網(wǎng)上搜拉一下,還不少,仔細(xì)看拉一下,但都不是很全有的還有錯誤,經(jīng)過幾天的實踐,把問題都解決拉,順便總結(jié)一下,希望對需要的朋友有點(diǎn)參考

          LOB中我們用的比較多的主要有兩種CLOB和BLOB,我們對兩種類型分別討論

          1.CLOB是字符型LOB,主要存儲文本信息,,最長為4G.,在J2EE程序中,比如網(wǎng)頁的textarea中的字符信息比較長,Varchar2字段類型不能滿足時,我們就得用CLOB數(shù)據(jù)類型,我們這次項目中就碰到這種情況.現(xiàn)在我們先說說如何存取CLOB字段

          現(xiàn)在我要把網(wǎng)頁中的textarea元素的信息保存到數(shù)據(jù)庫的CLOB字段中, 我們都知道textarea中的信息當(dāng)然不能直接保存成CLOB,我們在后臺得到的是String類型的,不多說拉,我們還是以一個實例講吧!

          先建一個test表,表有2個字段:ID,CONTENTS,其中CONTENTS保存CLOB類型的文本數(shù)據(jù)

          create table TEST
          (
          ID VARCHAR2(18) not null,
          CONTENTS CLOB,
          )

          接著我們編寫一個測試用的jsp文件ClobTest.jsp,代碼如下



          <%@ page language="java" contentType="text/html; charset=gb2312" %>

          <html>

          <head>

          <meta http-equiv="Content-Type" content="text/html; charset=gb2312">

          <title>Clob對象的存取測試</title>

          </head>



          <body>

          <form name="test" method="post" action="clobTest.action">

          <table width="80%" height="88" border="0" align="center" cellpadding="0" cellspacing="0">

          <tr>

          <td height="30" align="center">輸入ID號<input type="text" name="ID">

          </tr>

          <tr>

          <td align="center">

          <textarea rows="28" cols="68" name="CONTENTS">

          注冊用戶需遵守:

          尊重會員個人隱私、保障會員隱私安全是CSDN的一項基本政策,CSDN不會公開、編輯或透露會員的注冊資料,除非符合以下情況:
          (1) 根據(jù)中華人民共和國國家安全機(jī)構(gòu)、公安部門的要求及根據(jù)相應(yīng)的法律程序要求。
          (2) 維護(hù)CSDN的商標(biāo)所有權(quán)及其它權(quán)益。
          (3) 在緊急情況下竭力維護(hù)會員個人、其它社會個體和社會大眾的安全。
          (4) 嚴(yán)重違反CSDN有關(guān)規(guī)定。
          CSDN保留結(jié)束會員使用網(wǎng)絡(luò)服務(wù)資格的權(quán)利,并保證結(jié)束會員資格后仍為會員保密所有個人隱私。

          </textarea>

          </td>

          </tr>

          <tr>

          <td align="center">

          <input type="submit" name="Submit" value="提交">

          </td>

          </tr>

          </table>

          </form>

          </body>

          </html>

          點(diǎn)擊”提交”按鈕,我們在后臺的到的是2個String類型的對象

          String strID = request.getParameter(“ID”);

          String strCONTENTS = request.getParameter(“CONTENTS”);

          接著我們要做的任務(wù)就是如何把String類型CONTENTS存到數(shù)據(jù)庫中的CLOB類型字段中!

          注意:LOB數(shù)據(jù)不能象其它類型數(shù)據(jù)一樣直接插入(INSERT)。插入前必須先插入一個空的LOB對象,CLOB類型的空對象為EMPTY_CLOB(),BLOB類型的空對象為EMPTY_BLOB()。之后通過SELECT命令查詢得到先前插入的記錄并鎖定,繼而將空對象修改為所要插入的LOB對象。

          //我們先插入一個空的CLOB對象

          public int insertEmptyClob() throws Exception {

          Statement statement = null;

          int intResult = -1;

          try {

          //創(chuàng)建數(shù)據(jù)庫操作語句

          statement = connection.createStatement();

          //定義SQL語句

          String strSQL = “INSET INTO TEST (ID,CONTENTS) VALUES(strID, EMPTY_CLOB())”;

          //執(zhí)行SQL語句

          intResult = statement.executeUpdate(strSQL);

          System.out.println(" intResult valus is"+intResult);

          return intResult;

          } catch(Exception e) {

          e.printStackTrace();

          return -1;

          } finally {

          if (statement != null) {

          statement.close();

          }

          }

          }

          //把strCONTENT插入CLOB字段

          public void insertClob() throws Exception {

          Statement statement = null;

          ResultSet resultset = null;

          try {

          //設(shè)置不自動提交

          connection.setAutoCommit(false);

          //創(chuàng)建數(shù)據(jù)庫操作語句

          statement = connection.createStatement();

          //定義SQL語句

          String strSQL = “SELECT CONTENTS FROM TEST WHERE ID=strID"”

          resultset = statement.executeQuery(strSQL);

          oracle.sql.CLOB contents = null;

          while(resultset.next()) {

          //取出CLOB對象

          contents = (oracle.sql.CLOB)resultset.getClob("CONTENTS");

          }

          Writer out = contents.getCharacterOutputStream();

          out.write(strContents);

          out.flush();

          out.close();

          //數(shù)據(jù)庫提交

          connection.commit();

          } catch(Exception e) {

          e.printStackTrace();

          }finally{

          if(resultset != null) {

          resultset.close();

          }

          if(statement != null) {

          statement.close();

          }

          }

          }

          OK,我們已經(jīng)把這段文本以CLOB字段的形式保存到數(shù)據(jù)庫中了,在實際應(yīng)用中,如果要保存或修改一條記錄,我們要分2步做,先保存或修改非LOB字段類型的字段,再保存或修改LOB字段!接下來我們來把剛才保存到數(shù)據(jù)庫中的CLOB字段讀到j(luò)sp頁面中去。

          我們在保存的時候,CLOB字段會把上面textarea中的文本按原來的格式一行一行(包括空格)都保存到CLOB字段中,讀取的時候我們只要按照原來格式讀起出來就行了(我這里自己用了一個小處理方法,但如果你有更好的方法請告訴我)。在這里我們把CLOB讀到StringBuffer中,為了保存不同行我在行之間加了個“&”字符來區(qū)分。最后轉(zhuǎn)化成String

          放到VO中,這樣就保證從前臺到后臺,從后臺到前臺的數(shù)據(jù)傳遞的一致性!代碼如下:







          /**

          * 獲取CLOB文本對象

          * @param sbSQL

          * @return

          * @throws java.lang.Exception

          */

          public String selectIncludeClob(StringBuffer sbSQL) throws Exception {

          Statement stmt = null;

          ResultSet rs = null;

          StringBuffer sbResult = new StringBuffer();

          try {

          //設(shè)定數(shù)據(jù)庫不自動提交

          //connection.setAutoCommit(false);

          //創(chuàng)建數(shù)據(jù)庫操作語句

          stmt = connection.createStatement();

          //獲取結(jié)果集

          rs = stmt.executeQuery(sbSQL.toString());



          while(rs.next()) {

          CLOB clob = (CLOB)rs.getClob("CONTENTS");

          Reader isClob = clob.getCharacterStream();

          BufferedReader bfClob = new BufferedReader(isClob);

          String strClob = bfClob.readLine();

          while(strClob != null) {

          sbResult.append(strClob);

          sbResult.append("&");

          strClob = bfClob.readLine();

          }

          }

          //提交事務(wù)

          // connection.commit();

          } catch(Exception e) {

          e.printStackTrace();

          throw e;

          } finally {

          if(rs != null) {

          rs.close();

          }

          if(stmt != null) {

          stmt.close();

          }

          }

          return sbResult.toString();

          }

          到j(luò)sp頁面中,我們從VO中獲取改文本信息。

          <textarea rows="42" cols="68" name="CONTENTS" style="border-style: solid; border-color: #FFFFFF; font-family:仿宋_GB2312; font-size:14pt; line-height:200%; margin-top:8; margin-bottom:6" >

          <%

          String content = vo.getContent();

          String[] contentArray = content.split("&");

          for(int i=0;i<contentArray.length;i++) {

          String s= contentArray[i];

          out.println(s);

          }

          %>

          </textarea>

          這樣我們就保證什么格式保存就以什么格式顯示。

          2.BLOB字段,二進(jìn)制LOB,主要存儲二進(jìn)制數(shù)據(jù),最長為4G,在J2EE程序中,一般類似于圖片和文件的保存。當(dāng)然也有另一種方法,就把圖片和文件保存在硬盤上,數(shù)據(jù)庫中只保存圖片的鏈接地址和文件在服務(wù)器上的路徑。如果遇到文件和圖片比較重要的還是需要保存到數(shù)據(jù)庫中(例如:我們做國土資源項目的時候,好多圖片、文件就很重要,需要保存到數(shù)據(jù)庫中),下面我寫一個保存文件到數(shù)據(jù)庫的Blob字段和從數(shù)據(jù)庫的Blob字段中獲取文件的方法(當(dāng)然完全應(yīng)用還要做其他工作,這里就不多說了,如果你不清楚的可以問我):

          /**

          * 把上傳的文件保存到數(shù)據(jù)庫的Blob字段中

          * @param strTableName 對應(yīng)的表名稱

          * @param strColumnName 表中保存文件的Blob字段名稱

          * @param inputStream 輸入的文件流

          * @param sbSQLWhere where條件

          * @throws java.lang.Exception

          */

          public static void fileUpload(String strTableName,

          String strColumnName,

          InputStream inputStream,

          StringBuffer sbSQLWhere)

          throws Exception {

          Connection con = null;

          ResultSet resultset = null;

          Statement stmt = null;

          try {

          //得到數(shù)據(jù)庫連接

          con = DBConnector.getConnection();

          //構(gòu)建查詢語句

          StringBuffer sbSQL = new StringBuffer();

          sbSQL.append(" UPDATE ");

          sbSQL.append(strTableName);

          sbSQL.append(" SET ");

          sbSQL.append(strColumnName);

          sbSQL.append("=EMPTY_BLOB() ");

          sbSQL.append(sbSQLWhere);

          System.out.println(" update sql value is*******"+sbSQL.toString());

          //獲取數(shù)據(jù)庫操作語句

          stmt=con.createStatement();

          //插入空的blob對象

          stmt.executeUpdate(sbSQL.toString());

          con.setAutoCommit(false);

          StringBuffer sbSQLBlob = new StringBuffer();

          sbSQLBlob.append(" SELECT ");

          sbSQLBlob.append(strColumnName);

          sbSQLBlob.append(" FROM ");

          sbSQLBlob.append(strTableName);

          sbSQLBlob.append(sbSQLWhere);

          sbSQLBlob.append(" FOR UPDATE");

          System.out.println(" select sql value is*********"+sbSQL.toString());

          resultset =stmt.executeQuery(sbSQLBlob.toString());

          while (resultset.next()) {

          /* 取出此BLOB對象 */

          oracle.sql.BLOB blob = (oracle.sql.BLOB)resultset.getBlob("BODY");

          /* 向BLOB對象中寫入數(shù)據(jù) */

          BufferedOutputStream out = new BufferedOutputStream(blob.getBinaryOutputStream());

          BufferedInputStream in = new BufferedInputStream(inputStream);

          int c;

          while ((c=in.read())!=-1) {

          out.write(c);

          }

          in.close();

          out.close();

          }

          con.setAutoCommit(false);

          con.commit();

          } catch (Exception ex) {

          ex.printStackTrace();

          throw ex;

          } finally {

          if (stmt != null) {

          stmt.close();

          }

          if (resultset != null) {

          resultset.close();

          }

          if (con!=null) {

          con.close();

          }

          }

          }



          下面的方法是從數(shù)據(jù)庫中得到上傳的文件的輸入流,把輸入流寫到servlet流中,再從頁面中獲取,servlet就不寫了。

          /**

          * 方法描述:得到數(shù)據(jù)庫上傳的文件數(shù)據(jù)

          *

          * 輸入?yún)?shù): 1:表名(String)

          * 2:字段名(String)

          * 3: Where條件(StringBuffer)

          * 5: 輸出流(ServletOutputStream)

          *

          * 輸出參數(shù):void

          * 編寫人: */

          public static void getdownFile(String strTableName,

          String strColumnName,

          StringBuffer sbSQLWhere,

          ServletOutputStream sos) throws Exception {

          Connection con = null;

          PreparedStatement ps = null;

          ResultSet resultset = null;

          try {

          //得到數(shù)據(jù)庫連接

          con = DBConnector.getConnection();

          StringBuffer sbSQL = new StringBuffer();

          //構(gòu)建查詢語句

          sbSQL.append(" SELECT " + strColumnName + " FROM " + strTableName);

          sbSQL.append(sbSQLWhere);



          System.out.println(" sql value is:"+sbSQLWhere.toString());



          ps = con.prepareStatement(sbSQL.toString());

          //執(zhí)行查詢

          resultset = ps.executeQuery();

          while (resultset.next()) {

          //讀取數(shù)據(jù)流

          InputStream is = resultset.getBinaryStream(strColumnName);



          byte[] buf = new byte[2048];

          while(is.read(buf)!=-1) {

          //把數(shù)據(jù)流按塊寫到servlet的輸出流中

          sos.write(buf);

          }



          }

          } catch (Exception ex) {

          ex.printStackTrace();

          throw ex;

          } finally {

          if (ps != null) {

          ps.close();

          }

          if (resultset != null) {

          resultset.close();

          }

          if (con!=null) {

          con.close();

          }

          }

          }

          圖片的保存和文件的保存一樣,如果不清楚的可以和我聯(lián)系



          后記:

          平時總忙著做項目,閑的時候也很懶,總想把自己實際中的一些問題和解決方法小結(jié)一下,但總沒完成,這是第一次寫,寫的不好或不清楚的地方請包涵,下次改進(jìn),也希望大家多提意見,大家一起進(jìn)步!?。。。。。。。。?!

          posted @ 2007-01-16 16:14 一縷青煙 閱讀(195) | 評論 (0)編輯 收藏
          J2EE程序中使用oracle數(shù)據(jù)庫LOB字段的總結(jié)(elathen)
          ???http://www.souzz.net 2005-10-23 文章出處:博客園
          ?
          ????

          posted on 2005-05-27 09:36 輕松逍遙子

          最近在J2EE的項目中需要使用LOB字段保存文本信息以及圖片和文件,到網(wǎng)上搜拉一下,還不少,仔細(xì)看拉一下,但都不是很全有的還有錯誤,經(jīng)過幾天的實踐,把問題都解決拉,順便總結(jié)一下,希望對需要的朋友有點(diǎn)參考

          LOB中我們用的比較多的主要有兩種CLOB和BLOB,我們對兩種類型分別討論

          1.CLOB是字符型LOB,主要存儲文本信息,,最長為4G.,在J2EE程序中,比如網(wǎng)頁的textarea中的字符信息比較長,Varchar2字段類型不能滿足時,我們就得用CLOB數(shù)據(jù)類型,我們這次項目中就碰到這種情況.現(xiàn)在我們先說說如何存取CLOB字段

          現(xiàn)在我要把網(wǎng)頁中的textarea元素的信息保存到數(shù)據(jù)庫的CLOB字段中, 我們都知道textarea中的信息當(dāng)然不能直接保存成CLOB,我們在后臺得到的是String類型的,不多說拉,我們還是以一個實例講吧!

          先建一個test表,表有2個字段:ID,CONTENTS,其中CONTENTS保存CLOB類型的文本數(shù)據(jù)

          create table TEST
          (
          ID VARCHAR2(18) not null,
          CONTENTS CLOB,
          )

          接著我們編寫一個測試用的jsp文件ClobTest.jsp,代碼如下



          <%@ page language="java" contentType="text/html; charset=gb2312" %>

          <html>

          <head>

          <meta http-equiv="Content-Type" content="text/html; charset=gb2312">

          <title>Clob對象的存取測試</title>

          </head>



          <body>

          <form name="test" method="post" action="clobTest.action">

          <table width="80%" height="88" border="0" align="center" cellpadding="0" cellspacing="0">

          <tr>

          <td height="30" align="center">輸入ID號<input type="text" name="ID">

          </tr>

          <tr>

          <td align="center">

          <textarea rows="28" cols="68" name="CONTENTS">

          注冊用戶需遵守:

          尊重會員個人隱私、保障會員隱私安全是CSDN的一項基本政策,CSDN不會公開、編輯或透露會員的注冊資料,除非符合以下情況:
          (1) 根據(jù)中華人民共和國國家安全機(jī)構(gòu)、公安部門的要求及根據(jù)相應(yīng)的法律程序要求。
          (2) 維護(hù)CSDN的商標(biāo)所有權(quán)及其它權(quán)益。
          (3) 在緊急情況下竭力維護(hù)會員個人、其它社會個體和社會大眾的安全。
          (4) 嚴(yán)重違反CSDN有關(guān)規(guī)定。
          CSDN保留結(jié)束會員使用網(wǎng)絡(luò)服務(wù)資格的權(quán)利,并保證結(jié)束會員資格后仍為會員保密所有個人隱私。

          </textarea>

          </td>

          </tr>

          <tr>

          <td align="center">

          <input type="submit" name="Submit" value="提交">

          </td>

          </tr>

          </table>

          </form>

          </body>

          </html>

          點(diǎn)擊”提交”按鈕,我們在后臺的到的是2個String類型的對象

          String strID = request.getParameter(“ID”);

          String strCONTENTS = request.getParameter(“CONTENTS”);

          接著我們要做的任務(wù)就是如何把String類型CONTENTS存到數(shù)據(jù)庫中的CLOB類型字段中!

          注意:LOB數(shù)據(jù)不能象其它類型數(shù)據(jù)一樣直接插入(INSERT)。插入前必須先插入一個空的LOB對象,CLOB類型的空對象為EMPTY_CLOB(),BLOB類型的空對象為EMPTY_BLOB()。之后通過SELECT命令查詢得到先前插入的記錄并鎖定,繼而將空對象修改為所要插入的LOB對象。

          //我們先插入一個空的CLOB對象

          public int insertEmptyClob() throws Exception {

          Statement statement = null;

          int intResult = -1;

          try {

          //創(chuàng)建數(shù)據(jù)庫操作語句

          statement = connection.createStatement();

          //定義SQL語句

          String strSQL = “INSET INTO TEST (ID,CONTENTS) VALUES(strID, EMPTY_CLOB())”;

          //執(zhí)行SQL語句

          intResult = statement.executeUpdate(strSQL);

          System.out.println(" intResult valus is"+intResult);

          return intResult;

          } catch(Exception e) {

          e.printStackTrace();

          return -1;

          } finally {

          if (statement != null) {

          statement.close();

          }

          }

          }

          //把strCONTENT插入CLOB字段

          public void insertClob() throws Exception {

          Statement statement = null;

          ResultSet resultset = null;

          try {

          //設(shè)置不自動提交

          connection.setAutoCommit(false);

          //創(chuàng)建數(shù)據(jù)庫操作語句

          statement = connection.createStatement();

          //定義SQL語句

          String strSQL = “SELECT CONTENTS FROM TEST WHERE ID=strID"”

          resultset = statement.executeQuery(strSQL);

          oracle.sql.CLOB contents = null;

          while(resultset.next()) {

          //取出CLOB對象

          contents = (oracle.sql.CLOB)resultset.getClob("CONTENTS");

          }

          Writer out = contents.getCharacterOutputStream();

          out.write(strContents);

          out.flush();

          out.close();

          //數(shù)據(jù)庫提交

          connection.commit();

          } catch(Exception e) {

          e.printStackTrace();

          }finally{

          if(resultset != null) {

          resultset.close();

          }

          if(statement != null) {

          statement.close();

          }

          }

          }

          OK,我們已經(jīng)把這段文本以CLOB字段的形式保存到數(shù)據(jù)庫中了,在實際應(yīng)用中,如果要保存或修改一條記錄,我們要分2步做,先保存或修改非LOB字段類型的字段,再保存或修改LOB字段!接下來我們來把剛才保存到數(shù)據(jù)庫中的CLOB字段讀到j(luò)sp頁面中去。

          我們在保存的時候,CLOB字段會把上面textarea中的文本按原來的格式一行一行(包括空格)都保存到CLOB字段中,讀取的時候我們只要按照原來格式讀起出來就行了(我這里自己用了一個小處理方法,但如果你有更好的方法請告訴我)。在這里我們把CLOB讀到StringBuffer中,為了保存不同行我在行之間加了個“&”字符來區(qū)分。最后轉(zhuǎn)化成String

          放到VO中,這樣就保證從前臺到后臺,從后臺到前臺的數(shù)據(jù)傳遞的一致性!代碼如下:







          /**

          * 獲取CLOB文本對象

          * @param sbSQL

          * @return

          * @throws java.lang.Exception

          */

          public String selectIncludeClob(StringBuffer sbSQL) throws Exception {

          Statement stmt = null;

          ResultSet rs = null;

          StringBuffer sbResult = new StringBuffer();

          try {

          //設(shè)定數(shù)據(jù)庫不自動提交

          //connection.setAutoCommit(false);

          //創(chuàng)建數(shù)據(jù)庫操作語句

          stmt = connection.createStatement();

          //獲取結(jié)果集

          rs = stmt.executeQuery(sbSQL.toString());



          while(rs.next()) {

          CLOB clob = (CLOB)rs.getClob("CONTENTS");

          Reader isClob = clob.getCharacterStream();

          BufferedReader bfClob = new BufferedReader(isClob);

          String strClob = bfClob.readLine();

          while(strClob != null) {

          sbResult.append(strClob);

          sbResult.append("&");

          strClob = bfClob.readLine();

          }

          }

          //提交事務(wù)

          // connection.commit();

          } catch(Exception e) {

          e.printStackTrace();

          throw e;

          } finally {

          if(rs != null) {

          rs.close();

          }

          if(stmt != null) {

          stmt.close();

          }

          }

          return sbResult.toString();

          }

          到j(luò)sp頁面中,我們從VO中獲取改文本信息。

          <textarea rows="42" cols="68" name="CONTENTS" style="border-style: solid; border-color: #FFFFFF; font-family:仿宋_GB2312; font-size:14pt; line-height:200%; margin-top:8; margin-bottom:6" >

          <%

          String content = vo.getContent();

          String[] contentArray = content.split("&");

          for(int i=0;i<contentArray.length;i++) {

          String s= contentArray[i];

          out.println(s);

          }

          %>

          </textarea>

          這樣我們就保證什么格式保存就以什么格式顯示。

          2.BLOB字段,二進(jìn)制LOB,主要存儲二進(jìn)制數(shù)據(jù),最長為4G,在J2EE程序中,一般類似于圖片和文件的保存。當(dāng)然也有另一種方法,就把圖片和文件保存在硬盤上,數(shù)據(jù)庫中只保存圖片的鏈接地址和文件在服務(wù)器上的路徑。如果遇到文件和圖片比較重要的還是需要保存到數(shù)據(jù)庫中(例如:我們做國土資源項目的時候,好多圖片、文件就很重要,需要保存到數(shù)據(jù)庫中),下面我寫一個保存文件到數(shù)據(jù)庫的Blob字段和從數(shù)據(jù)庫的Blob字段中獲取文件的方法(當(dāng)然完全應(yīng)用還要做其他工作,這里就不多說了,如果你不清楚的可以問我):

          /**

          * 把上傳的文件保存到數(shù)據(jù)庫的Blob字段中

          * @param strTableName 對應(yīng)的表名稱

          * @param strColumnName 表中保存文件的Blob字段名稱

          * @param inputStream 輸入的文件流

          * @param sbSQLWhere where條件

          * @throws java.lang.Exception

          */

          public static void fileUpload(String strTableName,

          String strColumnName,

          InputStream inputStream,

          StringBuffer sbSQLWhere)

          throws Exception {

          Connection con = null;

          ResultSet resultset = null;

          Statement stmt = null;

          try {

          //得到數(shù)據(jù)庫連接

          con = DBConnector.getConnection();

          //構(gòu)建查詢語句

          StringBuffer sbSQL = new StringBuffer();

          sbSQL.append(" UPDATE ");

          sbSQL.append(strTableName);

          sbSQL.append(" SET ");

          sbSQL.append(strColumnName);

          sbSQL.append("=EMPTY_BLOB() ");

          sbSQL.append(sbSQLWhere);

          System.out.println(" update sql value is*******"+sbSQL.toString());

          //獲取數(shù)據(jù)庫操作語句

          stmt=con.createStatement();

          //插入空的blob對象

          stmt.executeUpdate(sbSQL.toString());

          con.setAutoCommit(false);

          StringBuffer sbSQLBlob = new StringBuffer();

          sbSQLBlob.append(" SELECT ");

          sbSQLBlob.append(strColumnName);

          sbSQLBlob.append(" FROM ");

          sbSQLBlob.append(strTableName);

          sbSQLBlob.append(sbSQLWhere);

          sbSQLBlob.append(" FOR UPDATE");

          System.out.println(" select sql value is*********"+sbSQL.toString());

          resultset =stmt.executeQuery(sbSQLBlob.toString());

          while (resultset.next()) {

          /* 取出此BLOB對象 */

          oracle.sql.BLOB blob = (oracle.sql.BLOB)resultset.getBlob("BODY");

          /* 向BLOB對象中寫入數(shù)據(jù) */

          BufferedOutputStream out = new BufferedOutputStream(blob.getBinaryOutputStream());

          BufferedInputStream in = new BufferedInputStream(inputStream);

          int c;

          while ((c=in.read())!=-1) {

          out.write(c);

          }

          in.close();

          out.close();

          }

          con.setAutoCommit(false);

          con.commit();

          } catch (Exception ex) {

          ex.printStackTrace();

          throw ex;

          } finally {

          if (stmt != null) {

          stmt.close();

          }

          if (resultset != null) {

          resultset.close();

          }

          if (con!=null) {

          con.close();

          }

          }

          }



          下面的方法是從數(shù)據(jù)庫中得到上傳的文件的輸入流,把輸入流寫到servlet流中,再從頁面中獲取,servlet就不寫了。

          /**

          * 方法描述:得到數(shù)據(jù)庫上傳的文件數(shù)據(jù)

          *

          * 輸入?yún)?shù): 1:表名(String)

          * 2:字段名(String)

          * 3: Where條件(StringBuffer)

          * 5: 輸出流(ServletOutputStream)

          *

          * 輸出參數(shù):void

          * 編寫人: */

          public static void getdownFile(String strTableName,

          String strColumnName,

          StringBuffer sbSQLWhere,

          ServletOutputStream sos) throws Exception {

          Connection con = null;

          PreparedStatement ps = null;

          ResultSet resultset = null;

          try {

          //得到數(shù)據(jù)庫連接

          con = DBConnector.getConnection();

          StringBuffer sbSQL = new StringBuffer();

          //構(gòu)建查詢語句

          sbSQL.append(" SELECT " + strColumnName + " FROM " + strTableName);

          sbSQL.append(sbSQLWhere);



          System.out.println(" sql value is:"+sbSQLWhere.toString());



          ps = con.prepareStatement(sbSQL.toString());

          //執(zhí)行查詢

          resultset = ps.executeQuery();

          while (resultset.next()) {

          //讀取數(shù)據(jù)流

          InputStream is = resultset.getBinaryStream(strColumnName);



          byte[] buf = new byte[2048];

          while(is.read(buf)!=-1) {

          //把數(shù)據(jù)流按塊寫到servlet的輸出流中

          sos.write(buf);

          }



          }

          } catch (Exception ex) {

          ex.printStackTrace();

          throw ex;

          } finally {

          if (ps != null) {

          ps.close();

          }

          if (resultset != null) {

          resultset.close();

          }

          if (con!=null) {

          con.close();

          }

          }

          }

          圖片的保存和文件的保存一樣,如果不清楚的可以和我聯(lián)系



          后記:

          平時總忙著做項目,閑的時候也很懶,總想把自己實際中的一些問題和解決方法小結(jié)一下,但總沒完成,這是第一次寫,寫的不好或不清楚的地方請包涵,下次改進(jìn),也希望大家多提意見,大家一起進(jìn)步?。。。。。。。。。?!

          posted @ 2007-01-16 16:14 一縷青煙 閱讀(239) | 評論 (0)編輯 收藏
          方法1:
          1. xmlhttp.setRequestHeader("Cache-Control","no-cache");
          2. url += "&random="+Math.random();
          3. url += "&timestamp="+new Date().getTime();

          方法二:

          //處理頁面緩存
          ??response.setHeader("Pragma","No-cache");
          ??response.setHeader("Cache-Control","no-cache");
          ??response.setDateHeader("Expires", 0);
          posted @ 2007-01-11 14:56 一縷青煙 閱讀(577) | 評論 (0)編輯 收藏

          正則表達(dá)式經(jīng)典 (轉(zhuǎn))
          "^\d+$"  //非負(fù)整數(shù)(正整數(shù) + 0)

          "^[0-9]*[1-9][0-9]*$"  //正整數(shù)

          "^((-\d+)|(0+))$"  //非正整數(shù)(負(fù)整數(shù) + 0)

          "^-[0-9]*[1-9][0-9]*$"  //負(fù)整數(shù)

          "^-?\d+$"    //整數(shù)

          "^\d+(\.\d+)?$"  //非負(fù)浮點(diǎn)數(shù)(正浮點(diǎn)數(shù) + 0)

          "^(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*))$"  //正浮點(diǎn)數(shù)

          "^((-\d+(\.\d+)?)|(0+(\.0+)?))$"  //非正浮點(diǎn)數(shù)(負(fù)浮點(diǎn)數(shù) + 0)

          "^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$"  //負(fù)浮點(diǎn)數(shù)

          "^(-?\d+)(\.\d+)?$"  //浮點(diǎn)數(shù)

          "^[A-Za-z]+$"  //由26個英文字母組成的字符串

          "^[A-Z]+$"  //由26個英文字母的大寫組成的字符串

          "^[a-z]+$"  //由26個英文字母的小寫組成的字符串

          "^[A-Za-z0-9]+$"  //由數(shù)字和26個英文字母組成的字符串

          "^\w+$"  //由數(shù)字、26個英文字母或者下劃線組成的字符串

          "^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$"    //email地址

          "^[a-zA-z]+://(\w+(-\w+)*)(\.(\w+(-\w+)*))*(\?\S*)?$"

          ----------------------------------------------------------------------------------------------------------------------

          字符描述: \:將下一個字符標(biāo)記為特殊字符或字面值。例如"n"與字符"n"匹配。"\n"與換行符匹配。序列"\\"與"\"匹配,"\("與"("匹配。

          ^ :匹配輸入的開始位置。

          $ :匹配輸入的結(jié)尾。

          * :匹配前一個字符零次或幾次。例如,"zo*"可以匹配"z"、"zoo"。

          + :匹配前一個字符一次或多次。例如,"zo+"可以匹配"zoo",但不匹配"z"。

          ? :匹配前一個字符零次或一次。例如,"a?ve?"可以匹配"never"中的"ve"。

          .:匹配換行符以外的任何字符。

          (pattern) 與模式匹配并記住匹配。匹配的子字符串可以從作為結(jié)果的 Matches 集合中使用 Item [0]...[n]取得。如果要匹配括號字符(和 ),可使用"\(" 或 "\)"。

          x|y:匹配 x 或 y。例如 "z|food" 可匹配 "z" 或 "food"。"(z|f)ood" 匹配 "zoo" 或 "food"。

          {n}:n 為非負(fù)的整數(shù)。匹配恰好n次。例如,"o{2}" 不能與 "Bob 中的 "o" 匹配,但是可以與"foooood"中的前兩個o匹配。

          {n,} :n 為非負(fù)的整數(shù)。匹配至少n次。例如,"o{2,}"不匹配"Bob"中的"o",但是匹配"foooood"中所有的o。"o{1,}"等價于"o+"。"o{0,}"等價于"o*"。

          {n,m} :m 和 n 為非負(fù)的整數(shù)。匹配至少 n 次,至多 m 次。例如,"o{1,3}" 匹配 "fooooood"中前三個o。"o{0,1}"等價于"o?"。

          [xyz] :一個字符集。與括號中字符的其中之一匹配。例如,"[abc]" 匹配"plain"中的"a"。

          [^xyz] :一個否定的字符集。匹配不在此括號中的任何字符。例如,"[^abc]" 可以匹配"plain"中的"p".

          [a-z] :表示某個范圍內(nèi)的字符。與指定區(qū)間內(nèi)的任何字符匹配。例如,"[a-z]"匹配"a"與"z"之間的任何一個小寫字母字符。

          [^m-z] :否定的字符區(qū)間。與不在指定區(qū)間內(nèi)的字符匹配。例如,"[m-z]"與不在"m"到"z"之間的任何字符匹配。

          \b :與單詞的邊界匹配,即單詞與空格之間的位置。例如,"er\b" 與"never"中的"er"匹配,但是不匹配"verb"中的"er"。

          \B :與非單詞邊界匹配。"ea*r\B"與"never early"中的"ear"匹配。

          \d :與一個數(shù)字字符匹配。等價于[0-9]。

          \D :與非數(shù)字的字符匹配。等價于[^0-9]。

          \f :與分頁符匹配。

          \n :與換行符字符匹配。

          \r :與回車字符匹配。

          \s :與任何白字符匹配,包括空格、制表符、分頁符等。等價于"[ \f\n\r\t\v]"。

          \S :與任何非空白的字符匹配。等價于"[^ \f\n\r\t\v]"。

          \t :與制表符匹配。

          \v :與垂直制表符匹配。

          \w :與任何單詞字符匹配,包括下劃線。等價于"[A-Za-z0-9_]"。

          \W :與任何非單詞字符匹配。等價于"[^A-Za-z0-9_]"。

          \num :匹配 num個,其中 num 為一個正整數(shù)。引用回到記住的匹配。例如,"(.)\1"匹配兩個連續(xù)的相同的字符。

          \n:匹配 n,其中n 是一個八進(jìn)制換碼值。八進(jìn)制換碼值必須是 1, 2 或 3 個數(shù)字長。

          例如,"\11" 和 "\011" 都與一個制表符匹配。"\0011"等價于"\001" 與 "1"。八進(jìn)制換碼值不得超過 256。否則,只有前兩個字符被視為表達(dá)式的一部分。允許在正則表達(dá)式中使用ASCII碼。

          \xn:匹配n,其中n是一個十六進(jìn)制的換碼值。十六進(jìn)制換碼值必須恰好為兩個數(shù)字長。例如,"\x41"匹配"A"。"\x041"等價于"\x04" 和 "1"。允許在正則表達(dá)式中使用 ASCII 碼。

             好了,常用的方法和屬性就是這些了,上面的語法介紹的已經(jīng)很詳細(xì)了,我們就沒有必要在羅嗦了,接下來我們來看看在具體的例子里面如何使用這些方法和屬性來校驗數(shù)據(jù)的合法性,我們還是舉個例子吧,比如,我們想要對用戶輸入的電子郵件進(jìn)行校驗,那么,什么樣的數(shù)據(jù)才算是一個合法的電子郵件呢?我可以這樣輸入:uestc95@263.net,當(dāng)然我也會這樣輸入:xxx@yyy.com.cn,但是這樣的輸入就是非法的:xxx@@com.cn或者@xxx.com.cn,等等,所以我們得出一個合法的電子郵件地址至少應(yīng)當(dāng)滿足以下幾個條件:

          1. 必須包含一個并且只有一個符號“@”

          2. 必須包含至少一個至多三個符號“.”

          3. 第一個字符不得是“@”或者“.”

          4. 不允許出現(xiàn)“@.”或者.@

          5. 結(jié)尾不得是字符“@”或者“.”

          所以根據(jù)以上的原則和上面表中的語法,我們很容易的就可以得到需要的模板如下:"(\w)+[@]{1}(\w)+[.]{1,3}(\w)+"

            接下來我們仔細(xì)分析一下這個模板,首先“\w”表示郵件的開始字符只能是包含下劃線的單詞字符,這樣,滿足了第三個條件;“[@]{1}”表示在電子郵件中應(yīng)當(dāng)匹配并且只能匹配一次字符“@”,滿足了條件一;同樣的“[.]{1,3}”表示在電子郵件中至少匹配1個至多匹配3個字符“.” ,滿足了第二個條件;模板最后的“(\w)+”表示結(jié)尾的字符只能是包含下劃線在內(nèi)的單詞字符,滿足了條件五;模板中間的“(\w)+”滿足了條件四。

            然后,我們就直接調(diào)用剛才的那個函數(shù)CheckExp("(\w)+[@]{1}(\w)+[.]{1}(\w)+",待校驗的字符串)就好了,如果返回True就表示數(shù)據(jù)是合法的,否則就是不正確的,怎么樣,簡單吧。我們還可以寫出來校驗身份證號碼的模板:"([0-9]){15}";校驗URL的模板:"^http://{1}((\w)+[.]){1,3}"等等;我們可以看到,這些模板為我們提供了很好的可重利用的模塊,利用自己或者別人提供的各種模板,我們就可以方便快捷的進(jìn)行數(shù)據(jù)的合法性校驗了,相信你一定會寫出非常通用的模板的。

            這樣,我們只要定制不同的模板,就可以實現(xiàn)對不同數(shù)據(jù)的合法性校驗了。所以,正則表達(dá)式對象中最重要的屬性就是:“Pattern”屬性,只要真正掌握了這個屬性,才可以自由的運(yùn)用正則表達(dá)式對象來為我們的數(shù)據(jù)校驗進(jìn)行服務(wù)。



          Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=560411

          posted @ 2006-12-04 09:36 一縷青煙 閱讀(259) | 評論 (0)編輯 收藏

          TCP協(xié)議 

          ==> TCP首部

          ??? 源端口號、目的端口號、位序號、位確認(rèn)序號、首部長度、標(biāo)志位、窗口大小、檢驗和、緊急指針和其它選項。
          ???
          ??? 一個IP地址和一個端口號也成為一個插口(socket)。插口對可唯一確定互聯(lián)網(wǎng)中每個TCP連接的雙方。


          ==> TCP連接的建立與終止

          ??? TCP是一個面向連接的協(xié)議,無論哪方向另一方發(fā)送數(shù)據(jù)之前,都必須先在雙方之間建立一條連接。
          ??? TCP連接的建立——三次握手。
          ??? TCP連接的終止——四次握手。這是由TCP的半關(guān)閉造成的。因為TCP是全雙工的,因此每個方向必須單獨(dú)的進(jìn)行關(guān)閉。


          ==> 最大報文段長度MSS

          ??? MSS越大,允許每個報文段傳遞的數(shù)據(jù)越多,相對TCP和IP的首部有更高的利用率。

          ??? 有些情況下,MSS是可以在建立TCP連接時進(jìn)行協(xié)商的選項,但是有些情況下不行 。

          ??? * 如果是本地網(wǎng)絡(luò),TCP可以根據(jù)網(wǎng)絡(luò)外出接口處的MTU值減去固定的IP首部(20)和TCP長度(20),對于以太網(wǎng),可以達(dá)到1460。

          ??? * 如果IP地址為非本地的,則MSS通常定為默認(rèn)值536字節(jié)(允許20字節(jié)的IP首部和20字節(jié)的TCP首部以適合576字節(jié)的IP數(shù)據(jù)報)。

          ??? MSS讓主機(jī)限制另一端發(fā)送數(shù)據(jù)的長度,同時也能控制它自己發(fā)送數(shù)據(jù)報的長度,避免較小MTU發(fā)生分片。


          ==> TCP的半關(guān)閉

          ??? TCP連接的一端在結(jié)束它的發(fā)送后還能接收來自另一端數(shù)據(jù)(直到它也發(fā)送FIN)的能力,這就是所謂的半關(guān)閉。應(yīng)用程序很少用到。


          ==> 復(fù)位報文段

          ??? * 不存在的端口(目的端口沒有進(jìn)程監(jiān)聽)。目的主機(jī)將對SYN請求返回一個RST報文段。(UDP則將產(chǎn)生一個端口不可達(dá)的信息)

          ??? * 異常終止。

          ??? * 檢測半打開的連接。


          ==> TCP服務(wù)器的設(shè)計

          ??? * 大多數(shù)TCP服務(wù)器的進(jìn)程是并發(fā)的.

          ??? * 只有處于監(jiān)聽的進(jìn)程才能處理客戶端的連接請求.

          ??? * TCP服務(wù)器可以對本地IP地址進(jìn)行限制,但是一般不能對遠(yuǎn)程IP地址進(jìn)行限制.

            




          Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=561075

          posted @ 2006-12-04 09:35 一縷青煙 閱讀(353) | 評論 (0)編輯 收藏

          關(guān)于Java棧與堆的思考
          1. 棧(stack)與堆(heap)都是Java用來在Ram中存放數(shù)據(jù)的地方。與C++不同,Java自動管理棧和堆,程序員不能直接地設(shè)置?;蚨选?/p>

          2. 棧的優(yōu)勢是,存取速度比堆要快,僅次于直接位于CPU中的寄存器。但缺點(diǎn)是,存在棧中的數(shù)據(jù)大小與生存期必須是確定的,缺乏靈活性。另外,棧數(shù)據(jù)可以共享,詳見第3點(diǎn)。堆的優(yōu)勢是可以動態(tài)地分配內(nèi)存大小,生存期也不必事先告訴編譯器,Java的垃圾收集器會自動收走這些不再使用的數(shù)據(jù)。但缺點(diǎn)是,由于要在運(yùn)行時動態(tài)分配內(nèi)存,存取速度較慢。

          3. Java中的數(shù)據(jù)類型有兩種。
          ? 一種是基本類型(primitive types), 共有8種,即int, short, long, byte, float, double, boolean, char(注意,并沒有string的基本類型)。這種類型的定義是通過諸如int a = 3; long b = 255L;的形式來定義的,稱為自動變量。值得注意的是,自動變量存的是字面值,不是類的實例,即不是類的引用,這里并沒有類的存在。如int a = 3; 這里的a是一個指向int類型的引用,指向3這個字面值。這些字面值的數(shù)據(jù),由于大小可知,生存期可知(這些字面值固定定義在某個程序塊里面,程序塊退出后,字段值就消失了),出于追求速度的原因,就存在于棧中。
          ? 另外,棧有一個很重要的特殊性,就是存在棧中的數(shù)據(jù)可以共享。假設(shè)我們同時定義

          ? int a = 3;
          ? int b = 3;

          ?? 編譯器先處理int a = 3;首先它會在棧中創(chuàng)建一個變量為a的引用,然后查找有沒有字面值為3的地址,沒找到,就開辟一個存放3這個字面值的地址,然后將a指向3的地址。接著處理int b = 3;在創(chuàng)建完b的引用變量后,由于在棧中已經(jīng)有3這個字面值,便將b直接指向3的地址。這樣,就出現(xiàn)了a與b同時均指向3的情況。

          ?? 特別注意的是,這種字面值的引用與類對象的引用不同。假定兩個類對象的引用同時指向一個對象,如果一個對象引用變量修改了這個對象的內(nèi)部狀態(tài),那么另一個對象引用變量也即刻反映出這個變化。相反,通過字面值的引用來修改其值,不會導(dǎo)致另一個指向此字面值的引用的值也跟著改變的情況。如上例,我們定義完a與 b的值后,再令a=4;那么,b不會等于4,還是等于3。在編譯器內(nèi)部,遇到a=4;時,它就會重新搜索棧中是否有4的字面值,如果沒有,重新開辟地址存放4的值;如果已經(jīng)有了,則直接將a指向這個地址。因此a值的改變不會影響到b的值。

          ? 另一種是包裝類數(shù)據(jù),如Integer, String, Double等將相應(yīng)的基本數(shù)據(jù)類型包裝起來的類。這些類數(shù)據(jù)全部存在于堆中,Java用new()語句來顯示地告訴編譯器,在運(yùn)行時才根據(jù)需要動態(tài)創(chuàng)建,因此比較靈活,但缺點(diǎn)是要占用更多的時間。

          4. String是一個特殊的包裝類數(shù)據(jù)。即可以用String str = new String("abc");的形式來創(chuàng)建,也可以用String str = "abc";的形式來創(chuàng)建(作為對比,在JDK 5.0之前,你從未見過Integer i = 3;的表達(dá)式,因為類與字面值是不能通用的,除了String。而在JDK 5.0中,這種表達(dá)式是可以的!因為編譯器在后臺進(jìn)行Integer i = new Integer(3)的轉(zhuǎn)換)。前者是規(guī)范的類的創(chuàng)建過程,即在Java中,一切都是對象,而對象是類的實例,全部通過new()的形式來創(chuàng)建。Java 中的有些類,如DateFormat類,可以通過該類的getInstance()方法來返回一個新創(chuàng)建的類,似乎違反了此原則。其實不然。該類運(yùn)用了單例模式來返回類的實例,只不過這個實例是在該類內(nèi)部通過new()來創(chuàng)建的,而getInstance()向外部隱藏了此細(xì)節(jié)。那為什么在String str = "abc";中,并沒有通過new()來創(chuàng)建實例,是不是違反了上述原則?其實沒有。

          5. 關(guān)于String str = "abc"的內(nèi)部工作。Java內(nèi)部將此語句轉(zhuǎn)化為以下幾個步驟:
          ? (1)先定義一個名為str的對String類的對象引用變量:String str;
          ?? (2)在棧中查找有沒有存放值為"abc"的地址,如果沒有,則開辟一個存放字面值為"abc"的地址,接著創(chuàng)建一個新的String類的對象o,并將o 的字符串值指向這個地址,而且在棧中這個地址旁邊記下這個引用的對象o。如果已經(jīng)有了值為"abc"的地址,則查找對象o,并返回o的地址。
          ? (3)將str指向?qū)ο髈的地址。
          ? 值得注意的是,一般String類中字符串值都是直接存值的。但像String str = "abc";這種場合下,其字符串值卻是保存了一個指向存在棧中數(shù)據(jù)的引用!
          ?
          ? 為了更好地說明這個問題,我們可以通過以下的幾個代碼進(jìn)行驗證。

          ? String str1 = "abc";
          ? String str2 = "abc";
          ? System.out.println(str1==str2);? //true
          ?
          ? 注意,我們這里并不用str1.equals(str2);的方式,因為這將比較兩個字符串的值是否相等。==號,根據(jù)JDK的說明,只有在兩個引用都指向了同一個對象時才返回真值。而我們在這里要看的是,str1與str2是否都指向了同一個對象。
          ? 結(jié)果說明,JVM創(chuàng)建了兩個引用str1和str2,但只創(chuàng)建了一個對象,而且兩個引用都指向了這個對象。

          ? 我們再來更進(jìn)一步,將以上代碼改成:

          ? String str1 = "abc";
          ? String str2 = "abc";
          ? str1 = "bcd";
          ? System.out.println(str1 + "," + str2);? //bcd, abc
          ? System.out.println(str1==str2);? //false

          ? 這就是說,賦值的變化導(dǎo)致了類對象引用的變化,str1指向了另外一個新對象!而str2仍舊指向原來的對象。上例中,當(dāng)我們將str1的值改為"bcd"時,JVM發(fā)現(xiàn)在棧中沒有存放該值的地址,便開辟了這個地址,并創(chuàng)建了一個新的對象,其字符串的值指向這個地址。
          ?? 事實上,String類被設(shè)計成為不可改變(immutable)的類。如果你要改變其值,可以,但JVM在運(yùn)行時根據(jù)新值悄悄創(chuàng)建了一個新對象,然后將這個對象的地址返回給原來類的引用。這個創(chuàng)建過程雖說是完全自動進(jìn)行的,但它畢竟占用了更多的時間。在對時間要求比較敏感的環(huán)境中,會帶有一定的不良影響。

          ? 再修改原來代碼:

          ? String str1 = "abc";
          ? String str2 = "abc";
          ?
          ? str1 = "bcd";
          ?
          ? String str3 = str1;
          ? System.out.println(str3);? //bcd

          ? String str4 = "bcd";
          ? System.out.println(str1 == str4);? //true
          ???
          ? str3 這個對象的引用直接指向str1所指向的對象(注意,str3并沒有創(chuàng)建新對象)。當(dāng)str1改完其值后,再創(chuàng)建一個String的引用str4,并指向因str1修改值而創(chuàng)建的新的對象??梢园l(fā)現(xiàn),這回str4也沒有創(chuàng)建新的對象,從而再次實現(xiàn)棧中數(shù)據(jù)的共享。

          ? 我們再接著看以下的代碼。

          ? String str1 = new String("abc");
          ? String str2 = "abc";
          ? System.out.println(str1==str2);? //false

          ? 創(chuàng)建了兩個引用。創(chuàng)建了兩個對象。兩個引用分別指向不同的兩個對象。

          ? String str1 = "abc";
          ? String str2 = new String("abc");
          ? System.out.println(str1==str2);? //false

          ? 創(chuàng)建了兩個引用。創(chuàng)建了兩個對象。兩個引用分別指向不同的兩個對象。

          ? 以上兩段代碼說明,只要是用new()來新建對象的,都會在堆中創(chuàng)建,而且其字符串是單獨(dú)存值的,即使與棧中的數(shù)據(jù)相同,也不會與棧中的數(shù)據(jù)共享。

          6. 數(shù)據(jù)類型包裝類的值不可修改。不僅僅是String類的值不可修改,所有的數(shù)據(jù)類型包裝類都不能更改其內(nèi)部的值。

          7. 結(jié)論與建議:

          ?? (1)我們在使用諸如String str = "abc";的格式定義類時,總是想當(dāng)然地認(rèn)為,我們創(chuàng)建了String類的對象str。擔(dān)心陷阱!對象可能并沒有被創(chuàng)建!唯一可以肯定的是,指向 String類的引用被創(chuàng)建了。至于這個引用到底是否指向了一個新的對象,必須根據(jù)上下文來考慮,除非你通過new()方法來顯要地創(chuàng)建一個新的對象。因此,更為準(zhǔn)確的說法是,我們創(chuàng)建了一個指向String類的對象的引用變量str,這個對象引用變量指向了某個值為"abc"的String類。清醒地認(rèn)識到這一點(diǎn)對排除程序中難以發(fā)現(xiàn)的bug是很有幫助的。

          ? (2)使用String str = "abc";的方式,可以在一定程度上提高程序的運(yùn)行速度,因為JVM會自動根據(jù)棧中數(shù)據(jù)的實際情況來決定是否有必要創(chuàng)建新對象。而對于String str = new String("abc");的代碼,則一概在堆中創(chuàng)建新對象,而不管其字符串值是否相等,是否有必要創(chuàng)建新對象,從而加重了程序的負(fù)擔(dān)。這個思想應(yīng)該是享元模式的思想,但JDK的內(nèi)部在這里實現(xiàn)是否應(yīng)用了這個模式,不得而知。

          ? (3)當(dāng)比較包裝類里面的數(shù)值是否相等時,用equals()方法;當(dāng)測試兩個包裝類的引用是否指向同一個對象時,用==。

          ? (4)由于String類的immutable性質(zhì),當(dāng)String變量需要經(jīng)常變換其值時,應(yīng)該考慮使用StringBuffer類,以提高程序效率。



          Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=561129

          posted @ 2006-12-04 09:31 一縷青煙 閱讀(461) | 評論 (0)編輯 收藏
          提高JSP應(yīng)用程序的七大秘籍絕招

          你時常被客戶抱怨JSP頁面響應(yīng)速度很慢嗎?你想過當(dāng)客戶訪問次數(shù)劇增時,你的WEB應(yīng)用能承受日益增加的訪問量嗎?本文講述了調(diào)整JSP和servlet的一些非常實用的方法,它可使你的servlet和JSP頁面響應(yīng)更快,擴(kuò)展性更強(qiáng)。而且在用戶數(shù)增加的情況下,系統(tǒng)負(fù)載會呈現(xiàn)出平滑上長的趨勢。在本文中,我將通過一些實際例子和配置方法使得你的應(yīng)用程序的性能有出人意料的提升。

          ???????其中,某些調(diào)優(yōu)技術(shù)是在你的編程工作中實現(xiàn)的。而另一些技術(shù)是與應(yīng)用服務(wù)器的配置相關(guān)的。在本文中,我們將詳細(xì)地描述怎樣通過調(diào)整servlet和JSP頁面,來提高你的應(yīng)用程序的總體性能。在閱讀本文之前,假設(shè)你有基本的servlet和JSP的知識。

          方法一:在servlet的init()方法中緩存數(shù)據(jù)

          當(dāng)應(yīng)用服務(wù)器初始化servlet實例之后,為客戶端請求提供服務(wù)之前,它會調(diào)用這個servlet的init()方法。在一個servlet的生命周期中,init()方法只會被調(diào)用一次。通過在init()方法中緩存一些靜態(tài)的數(shù)據(jù)或完成一些只需要執(zhí)行一次的、耗時的操作,就可大大地提高系統(tǒng)性能。

          例如,通過在init()方法中建立一個JDBC連接池是一個最佳例子,假設(shè)我們是用jdbc2.0的DataSource接口來取得數(shù)據(jù)庫連接,在通常的情況下,我們需要通過JNDI來取得具體的數(shù)據(jù)源。我們可以想象在一個具體的應(yīng)用中,如果每次SQL請求都要執(zhí)行一次JNDI查詢的話,那系統(tǒng)性能將會急劇下降。解決方法是如下代碼,它通過緩存DataSource,使得下一次SQL調(diào)用時仍然可以繼續(xù)利用它:

          public class ControllerServlet extends HttpServlet
          {
           private javax.sql.DataSource testDS = null; 
           public void init(ServletConfig config) throws ServletException
           {
            super.init(config); 
            Context ctx = null;
            try
            { 
             ctx = new InitialContext();
             testDS = (javax.sql.DataSource)ctx.lookup("jdbc/testDS");
            }
            catch(NamingException ne)
            {
             ne.printStackTrace(); 
            }
            catch(Exception e)
            {
             e.printStackTrace();
            }
           }
           public javax.sql.DataSource getTestDS()
           {
            return testDS;
           }
           ...
           ... 
          }


          方法 2:禁止servlet和JSP 自動重載(auto-reloading)

          ?????Servlet/JSP提供了一個實用的技術(shù),即自動重載技術(shù),它為開發(fā)人員提供了一個好的開發(fā)環(huán)境,當(dāng)你改變servlet和JSP頁面后而不必重啟應(yīng)用服務(wù)器。然而,這種技術(shù)在產(chǎn)品運(yùn)行階段對系統(tǒng)的資源是一個極大的損耗,因為它會給JSP引擎的類裝載器(classloader)帶來極大的負(fù)擔(dān)。因此關(guān)閉自動重載功能對系統(tǒng)性能的提升是一個極大的幫助。

          方法 3: 不要濫用HttpSession

          ?????在很多應(yīng)用中,我們的程序需要保持客戶端的狀態(tài),以便頁面之間可以相互聯(lián)系。但不幸的是由于HTTP具有天生無狀態(tài)性,從而無法保存客戶端的狀態(tài)。因此一般的應(yīng)用服務(wù)器都提供了session來保存客戶的狀態(tài)。在JSP應(yīng)用服務(wù)器中,是通過HttpSession對像來實現(xiàn)session的功能的,但在方便的同時,它也給系統(tǒng)帶來了不小的負(fù)擔(dān)。因為每當(dāng)你獲得或更新session時,系統(tǒng)者要對它進(jìn)行費(fèi)時的序列化操作。你可以通過對HttpSession的以下幾種處理方式來提升系統(tǒng)的性能。

          ????如果沒有必要,就應(yīng)該關(guān)閉JSP頁面中對HttpSession的缺省設(shè)置。 如果你沒有明確指定的話,每個JSP頁面都會缺省地創(chuàng)建一個HttpSession。如果你的JSP中不需要使用session的話,那可以通過如下的JSP頁面指示符來禁止它:

          <%@ page session="false"%>


          不要在HttpSession中存放大的數(shù)據(jù)對像:如果你在HttpSession中存放大的數(shù)據(jù)對像的話,每當(dāng)對它進(jìn)行讀寫時,應(yīng)用服務(wù)器都將對其進(jìn)行序列化,從而增加了系統(tǒng)的額外負(fù)擔(dān)。你在HttpSession中存放的數(shù)據(jù)對像越大,那系統(tǒng)的性能就下降得越快。

          ?????當(dāng)你不需要HttpSession時,盡快地釋放它:當(dāng)你不再需要session時,你可以通過調(diào)用HttpSession.invalidate()方法來釋放它。盡量將session的超時時間設(shè)得短一點(diǎn):在JSP應(yīng)用服務(wù)器中,有一個缺省的session的超時時間。當(dāng)客戶在這個時間之后沒有進(jìn)行任何操作的話,系統(tǒng)會將相關(guān)的session自動從內(nèi)存中釋放。超時時間設(shè)得越大,系統(tǒng)的性能就會越低,因此最好的方法就是盡量使得它的值保持在一個較低的水平。

          方法 4: 將頁面輸出進(jìn)行壓縮

          ????壓縮是解決數(shù)據(jù)冗余的一個好的方法,特別是在網(wǎng)絡(luò)帶寬不夠發(fā)達(dá)的今天。有的瀏覽器支持gzip(GNU zip)進(jìn)行來對HTML文件進(jìn)行壓縮,這種方法可以戲劇性地減少HTML文件的下載時間。因此,如果你將servlet或JSP頁面生成的HTML頁面進(jìn)行壓縮的話,那用戶就會覺得頁面瀏覽速度會非???。但不幸的是,不是所有的瀏覽器都支持gzip壓縮,但你可以通過在你的程序中檢查客戶的瀏覽器是否支持它。下面就是關(guān)于這種方法實現(xiàn)的一個代碼片段:

          public void doGet(HttpServletRequest request, 
          HttpServletResponse response)
          throws IOException, ServletException 
          {
           OutputStream out = null
           String encoding = request.getHeader("Accept-Encoding"); 
           if (encoding != null && encoding.indexOf("gzip") != -1)
           {
            request.setHeader("Content-Encoding" , "gzip");
            out = new GZIPOutputStream(request.getOutputStream());
           }
           else if (encoding != null && encoding.indexOf("compress") != -1)
           {
            request.setHeader("Content-Encoding" , "compress");
            out = new ZIPOutputStream(request.getOutputStream());
           } 
           else
           {
            out = request.getOutputStream();
           }
           ...
           ... 
          }


          方法 5: 使用線程池

          ????應(yīng)用服務(wù)器缺省地為每個不同的客戶端請求創(chuàng)建一個線程進(jìn)行處理,并為它們分派service()方法,當(dāng)service()方法調(diào)用完成后,與之相應(yīng)的線程也隨之撤消。由于創(chuàng)建和撤消線程會耗費(fèi)一定的系統(tǒng)資源,這種缺省模式降低了系統(tǒng)的性能。但所幸的是我們可以通過創(chuàng)建一個線程池來改變這種狀況。

          ????另外,我們還要為這個線程池設(shè)置一個最小線程數(shù)和一個最大線程數(shù)。在應(yīng)用服務(wù)器啟動時,它會創(chuàng)建數(shù)量等于最小線程數(shù)的一個線程池,當(dāng)客戶有請求時,相應(yīng)地從池從取出一個線程來進(jìn)行處理,當(dāng)處理完成后,再將線程重新放入到池中。如果池中的線程不夠地話,系統(tǒng)會自動地增加池中線程的數(shù)量,但總量不能超過最大線程數(shù)。通過使用線程池,當(dāng)客戶端請求急劇增加時,系統(tǒng)的負(fù)載就會呈現(xiàn)的平滑的上升曲線,從而提高的系統(tǒng)的可伸縮性。

          方法 6: 選擇正確的頁面包含機(jī)制

          在JSP中有兩種方法可以用來包含另一個頁面:

          1、使用include指示符

          <%@ includee file=”test.jsp” %>


          2、使用jsp指示符

          <jsp:includee page=”test.jsp” flush=”true”/>


          在實際中發(fā)現(xiàn),如果使用第一種方法的話,可以使得系統(tǒng)性能更高。

          方法 7:正確地確定javabean的生命周期

          ??????JSP的一個強(qiáng)大的地方就是對javabean的支持。通過在JSP頁面中使用<jsp:useBean>標(biāo)簽,可以將javabean直接插入到一個JSP頁面中。它的使用方法如下:

          <jsp:useBean id="name" scope="page|request|session|application" class="package.className" type="typeName">
          </jsp:useBean>


          其中scope屬性指出了這個bean的生命周期。缺省的生命周期為page。如果你沒有正確地選擇bean的生命周期的話,它將影響系統(tǒng)的性能。

          舉例來說,如果你只想在一次請求中使用某個bean,但你卻將這個bean的生命周期設(shè)置成了session,那當(dāng)這次請求結(jié)束后,這個bean將仍然保留在內(nèi)存中,除非session超時或用戶關(guān)閉瀏覽器。這樣會耗費(fèi)一定的內(nèi)存,并無謂的增加了JVM垃圾收集器的工作量。因此為bean設(shè)置正確的生命周期,并在bean的使命結(jié)束后盡快地清理它們,會使用系統(tǒng)性能有一個提高。

          其它一些有用的方法

          1、在字符串連接操作中盡量不使用“+”操作符:在java編程中,我們常常使用“+”操作符來將幾個字符串連接起來,但你或許從來沒有想到過它居然會對系統(tǒng)性能造成影響吧?由于字符串是常量,因此JVM會產(chǎn)生一些臨時的對像。你使用的“+”越多,生成的臨時對像就越多,這樣也會給系統(tǒng)性能帶來一些影響。解決的方法是用StringBuffer對像來代替“+”操作符。

          2、避免使用System.out.println()方法:由于System.out.println()是一種同步調(diào)用,即在調(diào)用它時,磁盤I/O操作必須等待它的完成,因此我們要盡量避免對它的調(diào)用。但我們在調(diào)試程序時它又是一個必不可少的方便工具,為了解決這個矛盾,我建議你最好使用Log4j工具(http://Jakarta.apache.org ),它既可以方便調(diào)試,而不會產(chǎn)生System.out.println()這樣的方法。

          3、ServletOutputStream 與 PrintWriter的權(quán)衡:使用PrintWriter可能會帶來一些小的開銷,因為它將所有的原始輸出都轉(zhuǎn)換為字符流來輸出,因此如果使用它來作為頁面輸出的話,系統(tǒng)要負(fù)擔(dān)一個轉(zhuǎn)換過程。而使用ServletOutputStream作為頁面輸出的話就不存在一個問題,但它是以二進(jìn)制進(jìn)行輸出的。因此在實際應(yīng)用中要權(quán)衡兩者的利弊。

          總結(jié)

          ?????本文的目的是通過對servlet和JSP的一些調(diào)優(yōu)技術(shù)來極大地提高你的應(yīng)用程序的性能,并因此提升整個J2EE應(yīng)用的性能。通過這些調(diào)優(yōu)技術(shù),你可以發(fā)現(xiàn)其實并不是某種技術(shù)平臺(比如J2EE和.NET之爭)決定了你的應(yīng)用程序的性能,重要是你要對這種平臺有一個較為深入的了解,這樣你才能從根本上對自己的應(yīng)用程序做一個優(yōu)化。

          本文來自:http://www.aygfsteel.com/sgsoft/articles/2378.html
          posted @ 2006-11-08 20:42 一縷青煙 閱讀(244) | 評論 (0)編輯 收藏

          版權(quán)所有,轉(zhuǎn)載請聲明出處 zhyiwww@163.com

          在讀我自己的認(rèn)識之前 , 我們先來看一下 servet 的結(jié)構(gòu)圖 :

          servlet.png
          以下是我自己的一點(diǎn)淺見:

          ①  Servlet 在初始化的時候 , 是通過 init(ServletConfig? config) init() 來執(zhí)行的。

          ServletConfig 是一個接口,它怎樣傳遞給他一格對象來進(jìn)行初始化呢?其實,是這個對象是由 servlet 容器來實例化的,由容器產(chǎn)生一格 ServletConfig 的實現(xiàn)類的對象,然后傳遞給 Servlet

          結(jié)論: ServletConfig 由容器實例化

          ②  我們有些時候可能在 Servlet 初始化時給它一些固定的配置參數(shù),那么這些參數(shù)是怎樣傳遞到 Servlet 呢?

          其實,我們在 web.xml 中給 servlet 配置啟動參數(shù),在容器對 servlet 進(jìn)行初始化的時候,會收集你所配置的參數(shù),記錄在 ServletConfig 的實現(xiàn)類中,所以你才可以通過 ServletConfig 對象的

          ??? public String getInitParameter(String name);

          ??? public Enumeration getInitParameterNames();

          方法來取得你已經(jīng)配置好的參數(shù),也就是說,你對 servlet 的配置都已經(jīng)記錄在 ServletConfig 對象中了。

          結(jié)論:你對 Servlet 的配置,在 Servlet 的初始化時都由容器來收集并且記錄到 ServletConfig 的實現(xiàn)類中。

          ?

          ③  我們來看一個 Servlet 的配置

          ? <servlet>

          ??? <servlet-name>index</servlet-name>

          ??? <servlet-class>org.zy.pro.sw.servlet.IndexServlet</servlet-class>

          ??? <init-param>

          ????? <param-name>dbconfig</param-name>

          ????? <param-value>/WEB-INF/dbconfig.xml</param-value>

          ??? </init-param>

          ? </servlet>

          在此,我們實現(xiàn)對數(shù)據(jù)庫的配置文件的加載。

          當(dāng) Servlet 初始化完成后,我們可以通過

          String? dbconf=this.getServletConfig().getInitParameter("dbconfig")

          來取得我們的配置的參數(shù)的值。

          但是,我們僅能得到一個配置的字符串。之后我們可以通過配置文件取得我們的數(shù)據(jù)庫的配置參數(shù),然后對數(shù)據(jù)庫進(jìn)行初始化。

          其實我們也可以通過傳遞一個類的名字串,然后再實例化。

          ??? <init-param>

          ????? <param-name>dbconfig</param-name>

          ????? <param-value>org.zy.util.db.DBUtil</param-value>

          ?? ?</init-param>

          我們先取得配置參數(shù):

          String? dbconf=this.getServletConfig().getInitParameter("dbconfig") ;

          然后通過

          Class.forName(dbconf).getInstance();

          來實例化對象,就可以實現(xiàn)對數(shù)據(jù)庫的調(diào)用了。

          結(jié)論:在 web.xml 中對 Servlet 的初始化,只能傳遞字符串類型的數(shù)據(jù)

          ④  ServletContext

          ServletContext 是負(fù)責(zé)和 Servlet 的上文和下文交互,上面和 Servlet 容器交互,下面和 Servlet 中的請求和相應(yīng)進(jìn)行交互。

          ServletConfig 中, ???

          public ServletContext getServletContext(); 方法實現(xiàn)取得當(dāng)前 ServletContext 的對象。

          你可能要問, ServletContext 是一個接口,那么你如何取得他的對象呢?

          其實這個問題和 ServletConfig 相同,都是在 Servlet 進(jìn)行初始化的時候產(chǎn)生的對象,是由容器來初始化的。

          posted @ 2006-10-30 19:54 一縷青煙 閱讀(423) | 評論 (0)編輯 收藏
          關(guān)于web打印的總結(jié)
          方案一:
          ???????調(diào)用瀏覽器的打印函數(shù)利用瀏覽器的模版
          ???源程序代碼:
          ?????????
          < OBJECT?id = " WebBrowser " ?classid = " CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 " ?height = " 0 "
          ????????????????width
          = " 0 " ?VIEWASTEXT >
          ????????????
          </ OBJECT >
          ?????說明:此代碼放在html?中?打印模版的指定框架為此代碼在的模塊;
          ??????調(diào)用程序:
          ??????
          < onclick = " parent.main.focus();parent.main.WebBrowser.ExecWB(7,1); "
          調(diào)用瀏覽器的對象中的方法
          < 2 > ?調(diào)用直接打印
          ??????
          < onclick = " parent.main.focus();parent.main.WebBrowser..print?(7,1); "
          < 3 > ?當(dāng)打印的時候不顯示時的css樣式
          ??????
          < style?media = " print " >
          .Noprint
          {display:none;}
          .PageNext
          {page - break - after:?always;}
          </ style >
          < style > .TdCs1? {?border:solid?windowtext? 1 .0pt;}
          .TdCs2?
          {?border:solid?windowtext? 1 .0pt;?border - left:none;}
          .TdCs3?
          {border - top:none;border - left:solid?windowtext? 1 .0pt;?border - bottom:solid?windowtext? 1 .0pt;?border - right:solid?windowtext? 1 .0pt;}
          .TdCs4?
          {border - top:none;??border - left:none;border - bottom:solid?windowtext? 1 .0pt;border - right:solid?windowtext? 1 .0pt;}
          .underline?
          {border - top - style:?none;border - right - style:?none;?border - bottom - style:?solid;?border - left - style:?none;border - bottom - color:?# 000000 ;}
          ????????
          </ style >
          ????
          < 4 > ?其余的設(shè)置
          ???
          < input?type = " button " ?value = " 打印 " ?onclick = " document.all.WebBrowser.ExecWB(6,1) " class = " NOPRINT " >
          < input?type = " button " ?value = " 直接打onclick= " document.all.WebBrowser.ExecWB( 6 , 6 ) " ?class= " NOPRINT " >
          < input?type = " button " ?value = " 頁面設(shè)置 " ?onclick = " document.all.WebBrowser.ExecWB(8,1) " ? class = " NOPRINT " >
          < input?type = " button " ?value = " 打印預(yù)覽 " ?onclick = " document.all.WebBrowser.ExecWB(7,1) " ? class = " NOPRINT " >


          <html>
          <head>
          <title>看看</title>
          <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
          <!--media=print 這個屬性可以在打印時有效-->
          <style media=print>
          .Noprint{display:none;}
          .PageNext{page-break-after: always;}
          </style>
          <style>
          .tdp
          {
          border-bottom: 1 solid #000000;
          border-left: 1 solid #000000;
          border-right: 0 solid #ffffff;
          border-top: 0 solid #ffffff;
          }
          .tabp
          {
          border-color: #000000 #000000 #000000 #000000;
          border-style: solid;
          border-top-width: 2px;
          border-right-width: 2px;
          border-bottom-width: 1px;
          border-left-width: 1px;
          }
          .NOPRINT {
          font-family: "宋體";
          font-size: 9pt;
          }
          </style>
          </head>
          <body >
          <center class="Noprint" >
          <p>
          <OBJECT id=WebBrowser classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 width=0>
          </OBJECT>
          <input type=button value=打印 onclick=document.all.WebBrowser.ExecWB(6,1)>
          <input type=button value=直接打印 onclick=document.all.WebBrowser.ExecWB(6,6)>
          <input type=button value=頁面設(shè)置 onclick=document.all.WebBrowser.ExecWB(8,1)>
          </p>
          <p> <input type=button value=打印預(yù)覽 onclick=document.all.WebBrowser.ExecWB(7,1)>
          <br/>
          </p>
          <hr align="center" width="90%" size="1" noshade>
          </center>
          <table width="90%" border="0" align="center" cellpadding="2" cellspacing="0" class="tabp">
          <tr>
          <td colspan="3" class="tdp">第1頁</td>
          </tr>
          <tr>
          <td width="29%" class="tdp"> </td>
          <td width="28%" class="tdp"> </td>
          <td width="43%" class="tdp"> </td>
          </tr>
          <tr>
          <td colspan="3" class="tdp"> </td>
          </tr>
          <tr>
          <td colspan="3" class="tdp"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
          <td width="50%" class="tdp"><p>這樣的報表</p>
          <p>對一般的要求就夠了。</p></td>
          <td> </td>
          </tr>
          </table></td>
          </tr>
          </table>
          <hr align="center" width="90%" size="1" noshade class="NOPRINT" >
          <!--分頁-->
          <div class="PageNext"></div>
          <table width="90%" border="0" align="center" cellpadding="2" cellspacing="0" class="tabp">
          <tr>
          <td class="tdp">第2頁</td>
          </tr>
          <tr>
          <td class="tdp">看到分頁了吧</td>
          </tr>
          <tr>
          <td class="tdp"> </td>
          </tr>
          <tr>
          <td class="tdp"> </td>
          </tr>
          <tr>
          <td class="tdp"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
          <td width="50%" class="tdp"><p>這樣的報表</p>
          <p>對一般的要求就夠了。</p></td>
          <td> </td>
          </tr>
          </table></td>
          </tr>
          </table>
          </body>
          </html>

          ?

          posted @ 2006-10-20 14:26 一縷青煙 閱讀(902) | 評論 (1)編輯 收藏

          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "<html xmlns="<title>Pure CSS Scrollable Table with Fixed Header</title>
          <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
          <meta http-equiv="language" content="en-us" />
          <script type="text/javascript">
          <!--
          /*
          http://www.alistapart.com/articles/zebratables/ */
          function removeClassName (elem, className) {
          ?elem.className = elem.className.replace(className, "").trim();
          }

          function addCSSClass (elem, className) {
          ?removeClassName (elem, className);
          ?elem.className = (elem.className + " " + className).trim();
          }

          String.prototype.trim = function() {
          ?return this.replace( /^\s+|\s+$/, "" );
          }

          function stripedTable() {
          ?if (document.getElementById && document.getElementsByTagName) {?
          ??var allTables = document.getElementsByTagName('table');
          ??if (!allTables) { return; }

          ??for (var i = 0; i < allTables.length; i++) {
          ???if (allTables[i].className.match(/[\w\s ]*scrollTable[\w\s ]*/)) {
          ????var trs = allTables[i].getElementsByTagName("tr");
          ????for (var j = 0; j < trs.length; j++) {
          ?????removeClassName(trs[j], 'alternateRow');
          ?????addCSSClass(trs[j], 'normalRow');
          ????}
          ????for (var k = 0; k < trs.length; k += 2) {
          ?????removeClassName(trs[k], 'normalRow');
          ?????addCSSClass(trs[k], 'alternateRow');
          ????}
          ???}
          ??}
          ?}
          }

          /* onload state is fired, append onclick action to the table's DIV */
          /* container. This allows the HTML document to validate correctly. */
          /* addIEonScroll added on 2005-01-28?????????????????????????????? */
          /* Terence Ordona, portal[AT]imaputz[DOT]com?????????????????????? */
          function addIEonScroll() {
          ?var thisContainer = document.getElementById('tableContainer');
          ?if (!thisContainer) { return; }

          ?var onClickAction = 'toggleSelectBoxes();';
          ?thisContainer.onscroll = new Function(onClickAction);
          }

          /* Only WinIE will fire this function. All other browsers scroll the TBODY element and not the DIV */
          /* This is to hide the SELECT elements from scrolling over the fixed Header. WinIE only.?????????? */
          /* toggleSelectBoxes added on 2005-01-28 */
          /* Terence Ordona, portal[AT]imaputz[DOT]com???????? */
          function toggleSelectBoxes() {
          ?var thisContainer = document.getElementById('tableContainer');
          ?var thisHeader = document.getElementById('fixedHeader');
          ?if (!thisContainer || !thisHeader) { return; }

          ?var selectBoxes = thisContainer.getElementsByTagName('select');
          ?if (!selectBoxes) { return; }

          ?for (var i = 0; i < selectBoxes.length; i++) {
          ??if (thisContainer.scrollTop >= eval(selectBoxes[i].parentNode.offsetTop - thisHeader.offsetHeight)) {
          ???selectBoxes[i].style.visibility = 'hidden';
          ??} else {
          ???selectBoxes[i].style.visibility = 'visible';
          ??}
          ?}
          }

          window.onload = function() { stripedTable(); addIEonScroll(); }
          -->
          </script>
          <style type="text/css">
          <!--
          /* Terence Ordona, portal[AT]imaputz[DOT]com???????? */
          /* http://creativecommons.org/licenses/by-sa/2.0/??? */

          /* begin some basic styling here???????????????????? */
          body {
          ?background: #FFF;
          ?color: #000;
          ?font: normal normal 12px Verdana, Geneva, Arial, Helvetica, sans-serif;
          ?margin: 10px;
          ?padding: 0
          }

          table, td, a {
          ?color: #000;
          ?font: normal normal 12px Verdana, Geneva, Arial, Helvetica, sans-serif
          }

          h1 {
          ?font: normal normal 18px Verdana, Geneva, Arial, Helvetica, sans-serif;
          ?margin: 0 0 5px 0
          }

          h2 {
          ?font: normal normal 16px Verdana, Geneva, Arial, Helvetica, sans-serif;
          ?margin: 0 0 5px 0
          }

          h3 {
          ?font: normal normal 13px Verdana, Geneva, Arial, Helvetica, sans-serif;
          ?color: #008000;
          ?margin: 0 0 15px 0
          }

          /* end basic styling???????????????????????????????? */


          /* define height and width of scrollable area. Add 16px to width for scrollbar????????? */
          /* allow WinIE to scale 100% width of browser by not defining a width?????????????????? */
          /* WARNING: applying a background here may cause problems with scrolling in WinIE 5.x?? */
          div.tableContainer {
          ?clear: both;
          ?border: 1px solid #963;
          ?height: 285px;
          ?overflow: auto;
          ?width: 756px;
          }

          /* WinIE 6.x needs to re-account for it's scrollbar. Give it some padding */
          \html div.tableContainer/* */ {
          ?padding: 0 16px 0 0;
          ?width: 740px;
          }

          /* clean up for allowing display Opera 5.x/6.x and MacIE 5.x */
          html>body div.tableContainer {
          ?height: auto;
          ?padding: 0;
          }

          /* Reset overflow value to hidden for all non-IE browsers. */
          /* Filter out Opera 5.x/6.x and MacIE 5.x????????????????? */
          head:first-child+body div[class].tableContainer {
          ?height: 285px;
          ?overflow: hidden;
          ?width: 756px
          }

          /* define width of table. IE browsers only???????????????? */
          /* if width is set to 100%, you can remove the width?????? */
          /* property from div.tableContainer and have the div scale */
          div.tableContainer table {
          ?float: left;
          ?width: 100%
          }

          /* WinIE 6.x needs to re-account for padding. Give it a negative margin */
          \html div.tableContainer table/* */ {
          ?margin: 0 -16px 0 0
          }

          /* define width of table. Opera 5.x/6.x and MacIE 5.x */
          html>body div.tableContainer table {
          ?float: none;
          ?margin: 0;
          ?width: 740px
          }

          /* define width of table. Add 16px to width for scrollbar.?????????? */
          /* All other non-IE browsers. Filter out Opera 5.x/6.x and MacIE 5.x */
          head:first-child+body div[class].tableContainer table {
          ?width: 756px
          }

          /* set table header to a fixed position. WinIE 6.x only?????????????????????????????????????? */
          /* In WinIE 6.x, any element with a position property set to relative and is a child of?????? */
          /* an element that has an overflow property set, the relative value translates into fixed.??? */
          /* Ex: parent element DIV with a class of tableContainer has an overflow property set to auto */
          thead.fixedHeader tr {
          ?position: relative;
          ?/* expression is for WinIE 5.x only. Remove to validate and for pure CSS solution????? */
          ?top: expression(document.getElementById("tableContainer").scrollTop);
          }

          /* set THEAD element to have block level attributes. All other non-IE browsers??????????? */
          /* this enables overflow to work on TBODY element. All other non-IE, non-Mozilla browsers */
          /* Filter out Opera 5.x/6.x and MacIE 5.x???????????????????????????????????????????????? */
          head:first-child+body thead[class].fixedHeader tr {
          ?display: block;
          }

          /* make the TH elements pretty */
          thead.fixedHeader th {
          ?background: #C96;
          ?border-left: 1px solid #EB8;
          ?border-right: 1px solid #B74;
          ?border-top: 1px solid #EB8;
          ?font-weight: normal;
          ?padding: 4px 3px;
          ?text-align: left
          }

          /* make the A elements pretty. makes for nice clickable headers??????????????? */
          thead.fixedHeader a, thead.fixedHeader a:link, thead.fixedHeader a:visited {
          ?color: #FFF;
          ?display: block;
          ?text-decoration: none;
          ?width: 100%
          }

          /* make the A elements pretty. makes for nice clickable headers??????????????? */
          /* WARNING: swapping the background on hover may cause problems in WinIE 6.x?? */
          thead.fixedHeader a:hover {
          ?color: #FFF;
          ?display: block;
          ?text-decoration: underline;
          ?width: 100%
          }

          /* define the table content to be scrollable????????????????????????????????????????????? */
          /* set TBODY element to have block level attributes. All other non-IE browsers??????????? */
          /* this enables overflow to work on TBODY element. All other non-IE, non-Mozilla browsers */
          /* induced side effect is that child TDs no longer accept width: auto???????????????????? */
          /* Filter out Opera 5.x/6.x and MacIE 5.x???????????????????????????????????????????????? */
          head:first-child+body tbody[class].scrollContent {
          ?display: block;
          ?height: 262px;
          ?overflow: auto;
          ?width: 100%
          }

          /* make TD elements pretty. Provide alternating classes for striping the table */
          /* http://www.alistapart.com/articles/zebratables/???????????????????????????? */
          tbody.scrollContent td, tbody.scrollContent tr.normalRow td {
          ?background: #FFF;
          ?border-bottom: none;
          ?border-left: none;
          ?border-right: 1px solid #CCC;
          ?border-top: 1px solid #DDD;
          ?padding: 2px 3px 3px 4px
          }

          tbody.scrollContent tr.alternateRow td {
          ?background: #EEE;
          ?border-bottom: none;
          ?border-left: none;
          ?border-right: 1px solid #CCC;
          ?border-top: 1px solid #DDD;
          ?padding: 2px 3px 3px 4px
          }

          /* define width of TH elements: 1st, 2nd, and 3rd respectively.????? */
          /* All other non-IE browsers. Filter out Opera 5.x/6.x and MacIE 5.x */
          /* Add 16px to last TH for scrollbar padding???????????????????????? */
          /* http://www.w3.org/TR/REC-CSS2/selector.html#adjacent-selectors??? */
          head:first-child+body thead[class].fixedHeader th {
          ?width: 200px
          }

          head:first-child+body thead[class].fixedHeader th + th {
          ?width: 240px
          }

          head:first-child+body thead[class].fixedHeader th + th + th {
          ?border-right: none;
          ?padding: 4px 4px 4px 3px;
          ?width: 316px
          }

          /* define width of TH elements: 1st, 2nd, and 3rd respectively.????? */
          /* All other non-IE browsers. Filter out Opera 5.x/6.x and MacIE 5.x */
          /* Add 16px to last TH for scrollbar padding???????????????????????? */
          /* http://www.w3.org/TR/REC-CSS2/selector.html#adjacent-selectors??? */
          head:first-child+body tbody[class].scrollContent td {
          ?width: 200px
          }

          head:first-child+body tbody[class].scrollContent td + td {
          ?width: 240px
          }

          head:first-child+body tbody[class].scrollContent td + td + td {
          ?border-right: none;
          ?padding: 2px 4px 2px 3px;
          ?width: 300px
          }
          -->
          </style>
          </head><body>

          <h1>(Almost) Pure CSS Scrollable Table with Fixed Header</h1>
          <h2>Using CSS to allow scrolling within a single HTML table</h2>

          <div><br/></div>

          <h2>The Bullet Resistant Version</h2>
          <h3>Lots of CSS Browser Filtering</h3>

          <form id="sampleForm" action="bulletVersion.html" method="post">
          <div id="tableContainer" class="tableContainer">
          <table border="0" cellpadding="0" cellspacing="0" width="100%" class="scrollTable">
          <thead class="fixedHeader" id="fixedHeader">
          ?<tr>
          ??<th><a href="#">Header 1</a></th>
          ??<th><a href="#">Header 2</a></th>
          ??<th><a href="#">Header 3</a></th>
          ?</tr>
          </thead>
          <tbody class="scrollContent">
          ?<tr>
          ??<td>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nulla vitae wisi. Nulla euismod aliquet tellus.</td>
          ??<td>In sit amet enim. Praesent vulputate tortor nec ante. Morbi sollicitudin est non neque.</td>
          ??<td>Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos.</td>
          ?</tr>
          ?<tr>
          ??<td>Cell Content 1</td>
          ??<td>Cell Content 2</td>
          ??<td><select name="sampleSelect1" id="sampleSelect1"><option>Option 1</option><option>Option 2</option><option>Option 3</option><option>Option 4</option><option>Option 5</option></select></td>
          ?</tr>
          ?<tr>
          ??<td>Cell Content 1</td>
          ??<td>Cell Content 2</td>
          ??<td><select name="sampleSelect2" id="sampleSelect2" size="5" multiple="multiple"><option>Option 1</option><option>Option 2</option><option>Option 3</option><option>Option 4</option><option>Option 5</option></select></td>
          ?</tr>
          ?<tr>
          ??<td>More Cell Content 1</td>
          ??<td>More Cell Content 2</td>
          ??<td><input type="text" name="sampleText" id="sampleText" value="This is a sample Text form element" /></td>
          ?</tr>
          ?<tr>
          ??<td>Even More Cell Content 1</td>
          ??<td>Even More Cell Content 2</td>
          ??<td><input type="password" name="samplePassword" id="samplePassword" value="password" /></td>
          ?</tr>
          ?<tr>
          ??<td>And Repeat 1</td>
          ??<td>And Repeat 2</td>
          ??<td><input type="submit" name="sampleSubmit" id="sampleSubmit" value="Sample Submit Button" /></td>
          ?</tr>
          ?<tr>
          ??<td>Cell Content 1</td>
          ??<td>Cell Content 2</td>
          ??<td><input type="reset" name="sampleReset" id="sampleReset" value="Sample Reset Button" /></td>
          ?</tr>
          ?<tr>
          ??<td>More Cell Content 1</td>
          ??<td>More Cell Content 2</td>
          ??<td><input type="button" name="sampleButton" id="sampleButton" value="Sample Button Element" /></td>
          ?</tr>
          ?<tr>
          ??<td>Even More Cell Content 1</td>
          ??<td>Even More Cell Content 2</td>
          ??<td><input type="checkbox" name="sampleCheckbox" id="sampleCheckboxA" value="sampleCheckboxA" /> <label for="sampleCheckboxA">Sample Checkbox A</label></td>
          ?</tr>
          ?<tr>
          ??<td>And Repeat 1</td>
          ??<td>And Repeat 2</td>
          ??<td><input type="checkbox" name="sampleCheckbox" id="sampleCheckboxB" value="sampleCheckboxB" /> <label for="sampleCheckboxB">Sample Checkbox B</label></td>
          ?</tr>
          ?<tr>
          ??<td>Cell Content 1</td>
          ??<td>Cell Content 2</td>
          ??<td><input type="radio" name="sampleRadio" id="sampleRadioA" value="sampleRadioA" /> <label for="sampleRadioA">Sample Radio A</label></td>
          ?</tr>
          ?<tr>
          ??<td>More Cell Content 1</td>
          ??<td>More Cell Content 2</td>
          ??<td><input type="radio" name="sampleRadio" id="sampleRadioB" value="sampleRadioB" /> <label for="sampleRadioB">Sample Radio B</label></td>
          ?</tr>
          ?<tr>
          ??<td>Even More Cell Content 1</td>
          ??<td>Even More Cell Content 2</td>
          ??<td><select name="sampleSelect3" id="sampleSelect3"><option>Option 1</option><option>Option 2</option><option>Option 3</option><option>Option 4</option><option>Option 5</option></select></td>
          ?</tr>
          ?<tr>
          ??<td>And Repeat 1</td>
          ??<td>And Repeat 2</td>
          ??<td><select name="sampleSelect4" id="sampleSelect4" size="5" multiple="multiple"><option>Option 1</option><option>Option 2</option><option>Option 3</option><option>Option 4</option><option>Option 5</option></select></td>
          ?</tr>
          ?<tr>
          ??<td>Cell Content 1</td>
          ??<td>Cell Content 2</td>
          ??<td><textarea cols="20" rows="5" name="sampleTextarea" id="sampleTextarea">Cell Content 3</textarea></td>
          ?</tr>
          ?<tr>
          ??<td>More Cell Content 1</td>
          ??<td>More Cell Content 2</td>
          ??<td>More Cell Content 3</td>
          ?</tr>
          ?<tr>
          ??<td>Even More Cell Content 1</td>
          ??<td>Even More Cell Content 2</td>
          ??<td>Even More Cell Content 3</td>
          ?</tr>
          ?<tr>
          ??<td>And Repeat 1</td>
          ??<td>And Repeat 2</td>
          ??<td>And Repeat 3</td>
          ?</tr>
          ?<tr>
          ??<td>Cell Content 1</td>
          ??<td>Cell Content 2</td>
          ??<td><select name="sampleSelect5" id="sampleSelect5"><option>Option 1</option><option>Option 2</option><option>Option 3</option><option>Option 4</option><option>Option 5</option></select></td>
          ?</tr>
          ?<tr>
          ??<td>More Cell Content 1</td>
          ??<td>More Cell Content 2</td>
          ??<td><select name="sampleSelect6" id="sampleSelect6"><option>Option 1</option><option>Option 2</option><option>Option 3</option><option>Option 4</option><option>Option 5</option></select></td>
          ?</tr>
          ?<tr>
          ??<td>Even More Cell Content 1</td>
          ??<td>Even More Cell Content 2</td>
          ??<td>Even More Cell Content 3</td>
          ?</tr>
          ?<tr>
          ??<td>And Repeat 1</td>
          ??<td>And Repeat 2</td>
          ??<td>And Repeat 3</td>
          ?</tr>
          ?<tr>
          ??<td>Cell Content 1</td>
          ??<td>Cell Content 2</td>
          ??<td>Cell Content 3</td>
          ?</tr>
          ?<tr>
          ??<td>More Cell Content 1</td>
          ??<td>More Cell Content 2</td>
          ??<td>More Cell Content 3</td>
          ?</tr>
          ?<tr>
          ??<td>Even More Cell Content 1</td>
          ??<td>Even More Cell Content 2</td>
          ??<td>Even More Cell Content 3</td>
          ?</tr>
          ?<tr>
          ??<td>And Repeat 1</td>
          ??<td>And Repeat 2</td>
          ??<td>And Repeat 3</td>
          ?</tr>
          ?<tr>
          ??<td>Cell Content 1</td>
          ??<td>Cell Content 2</td>
          ??<td>Cell Content 3</td>
          ?</tr>
          ?<tr>
          ??<td>More Cell Content 1</td>
          ??<td>More Cell Content 2</td>
          ??<td>More Cell Content 3</td>
          ?</tr>
          ?<tr>
          ??<td>Even More Cell Content 1</td>
          ??<td>Even More Cell Content 2</td>
          ??<td>Even More Cell Content 3</td>
          ?</tr>
          ?<tr>
          ??<td>And Repeat 1</td>
          ??<td>And Repeat 2</td>
          ??<td>And Repeat 3</td>
          ?</tr>
          ?<tr>
          ??<td>Cell Content 1</td>
          ??<td>Cell Content 2</td>
          ??<td>Cell Content 3</td>
          ?</tr>
          ?<tr>
          ??<td>More Cell Content 1</td>
          ??<td>More Cell Content 2</td>
          ??<td>More Cell Content 3</td>
          ?</tr>
          ?<tr>
          ??<td>Even More Cell Content 1</td>
          ??<td>Even More Cell Content 2</td>
          ??<td>Even More Cell Content 3</td>
          ?</tr>
          ?<tr>
          ??<td>And Repeat 1</td>
          ??<td>And Repeat 2</td>
          ??<td>And Repeat 3</td>
          ?</tr>
          ?<tr>
          ??<td>Cell Content 1</td>
          ??<td>Cell Content 2</td>
          ??<td>Cell Content 3</td>
          ?</tr>
          ?<tr>
          ??<td>More Cell Content 1</td>
          ??<td>More Cell Content 2</td>
          ??<td>More Cell Content 3</td>
          ?</tr>
          ?<tr>
          ??<td>Even More Cell Content 1</td>
          ??<td>Even More Cell Content 2</td>
          ??<td>Even More Cell Content 3</td>
          ?</tr>
          ?<tr>
          ??<td>And Repeat 1</td>
          ??<td>And Repeat 2</td>
          ??<td>And Repeat 3</td>
          ?</tr>
          ?<tr>
          ??<td>Cell Content 1</td>
          ??<td>Cell Content 2</td>
          ??<td>Cell Content 3</td>
          ?</tr>
          ?<tr>
          ??<td>More Cell Content 1</td>
          ??<td>More Cell Content 2</td>
          ??<td>More Cell Content 3</td>
          ?</tr>
          ?<tr>
          ??<td>Even More Cell Content 1</td>
          ??<td>Even More Cell Content 2</td>
          ??<td>Even More Cell Content 3</td>
          ?</tr>
          ?<tr>
          ??<td>And Repeat 1</td>
          ??<td>And Repeat 2</td>
          ??<td>And Repeat 3</td>
          ?</tr>
          ?<tr>
          ??<td>Cell Content 1</td>
          ??<td>Cell Content 2</td>
          ??<td>Cell Content 3</td>
          ?</tr>
          ?<tr>
          ??<td>More Cell Content 1</td>
          ??<td>More Cell Content 2</td>
          ??<td>More Cell Content 3</td>
          ?</tr>
          ?<tr>
          ??<td>Even More Cell Content 1</td>
          ??<td>Even More Cell Content 2</td>
          ??<td>Even More Cell Content 3</td>
          ?</tr>
          ?<tr>
          ??<td>End of Cell Content 1</td>
          ??<td>End of Cell Content 2</td>
          ??<td>End of Cell Content 3</td>
          ?</tr>
          </tbody>
          </table>
          </div>
          </form>

          <div>

          ?<p>Also see the <a href=" Big Four Version</a> :: Support for current generation of the four major Browsers</p>

          ?<h3>Browser Support (table is scrollable with fixed headers)</h3>

          ?<ul>
          ??<li>Opera 7.x + (All Platforms) :: Tested with 7.2x and 7.5x</li>
          ??<li>Mozilla 1.x + (All Platforms) :: Tested with 1.0x and 1.6x</li>
          ??<li>IE 6.x + (Windows) :: Tested with 6.0x</li>
          ??<li>IE 5.x + (Windows) :: Tested with 5.0x and 5.5x</li>
          ??<li>Safari 1.x + (MacOS) :: Tested with 1.2x</li>
          ??<li>Konqueror 3.x + (Linux / BSD) :: Tested with 3.2x</li>
          ?</ul>

          ?<h3>Almost works (table is viewable)</h3>

          ?<ul>
          ??<li>IE 5.x + (MacOS) :: Tested with 5.2x</li>
          ??<li>Opera 5.x and 6.x :: Tested with 5.1x and 6.x</li>
          ?</ul>

          ?<h3>Degrades gracefully</h3>

          ?<ul>
          ??<li>All other non-supporting browsers</li>
          ?</ul>

          ?<h3>Notes:</h3>

          ?<ul>
          ??<li>Opera v5 to v7 adds margins to the THEAD and TBODY and their children</li>
          ??<li>On Konqueror 3.x the scrollbar may be slightly off.</li>
          ??<li>On Konqueror 3.x form elements may not hide correctly.</li>
          ??<li>On MacIE 5.x the last table header cell may obscure the up arrow of the scrollbar.</li>
          ??<li>Gecko/20041217 may have table cell alignment issues (bug?), Prior versions (eg: Gecko/20040113) do not have this</li>
          ?</ul>

          ?<h3>Updates:</h3>

          ?<ul>
          ??<li>2004.10.15 11am: Added link to Big Four Version</li>
          ??<li>2004.11.02 01pm: Fixed incorrect width on 2nd Cell. Was 250px, should be 240px.</li>
          ??<li>2005.01.28 07pm: Added form elements to aid in testing scrolling abilities</li>
          ??<li>2005.01.28 08pm: Added JS IE Select element workaround.</li>
          ?</ul>

          </div>

          <div>
          <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
          put a bunch of breaks to test scrolling within the HTML document itself.
          <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
          put a bunch of breaks to test scrolling within the HTML document itself.
          <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
          put a bunch of breaks to test scrolling within the HTML document itself.
          <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
          done.
          </div>

          </body></html>

          posted @ 2006-10-20 10:05 一縷青煙 閱讀(295) | 評論 (0)編輯 收藏
          http://www.imaputz.com/cssStuff/bulletVersion.html
          posted @ 2006-10-20 09:47 一縷青煙 閱讀(253) | 評論 (0)編輯 收藏
          主站蜘蛛池模板: 天祝| 宁国市| 荥阳市| 日照市| 保亭| 若尔盖县| 维西| 新丰县| 铅山县| 建阳市| 肇东市| 肃宁县| 石家庄市| 潞西市| 延津县| 琼中| 尤溪县| 留坝县| 武安市| 临沂市| 富民县| 博客| 砀山县| 江口县| 永靖县| 丰县| 正安县| 财经| 景德镇市| 营山县| 会同县| 三门峡市| 龙陵县| 广汉市| 上思县| 松江区| 昌都县| 水城县| 靖江市| 禄劝| 夏邑县|