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

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

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

    陌上花開(kāi)

    遇高山,我御風(fēng)而翔,逢江河,我凌波微波

       :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::

    2010年5月12日 #

    標(biāo)準(zhǔn)javascript 是內(nèi)含支持hash關(guān)聯(lián)數(shù)組,經(jīng)查找資料并測(cè)試,有關(guān)標(biāo)準(zhǔn)javascript內(nèi)含的hash關(guān)聯(lián)數(shù)組操作備忘如下

    1。Hash關(guān)聯(lián)數(shù)組定義

    // 定義空數(shù)組
    myhash = { }

    // 直接定義數(shù)組
    myhash = {”key1″:”val1″, “key2″:”val2″ }

    // 用Array 定義數(shù)組
    myhash = new Array();
    myhash[”key1″] = “val1″;
    myhash[”key2″] = “val2″;

    2。向Hash關(guān)聯(lián)數(shù)組添加鍵值

    // 添加一個(gè)新鍵 newkey ,鍵值為 newval
    myhash[”newkey”] = “newval”;

    3。刪除Hash關(guān)聯(lián)數(shù)組已有鍵值

    // 刪除一個(gè)鍵 newkey ,同時(shí),該鍵值對(duì)應(yīng)的 newval 也就消失了
    delete myhash[”newkey”];

    4。遍歷Hash關(guān)聯(lián)數(shù)組

    // 遍歷整個(gè)hash 數(shù)組
    for (key in myhash) {
    val = myhash[key];
    }

    5。Hash關(guān)聯(lián)數(shù)組簡(jiǎn)易使用示例

    // 轉(zhuǎn)向腳本
    <script type=”text/javascript”>
    urlhash = { “yahoo”:”www.yahoo.cn“,
    “baidu”:”www.baidu.com“,
    “google”:”www.google.cn” };

    // 交互式使用示例
    userinfo = prompt(”請(qǐng)輸入您最想去的搜索引擎:(yahoo|baidu|google)”, “yahoo”);
    document.write (”您的選擇:” + userinfo + “,<a href=http://” + getURL(userinfo) + ” target=_blank>” + “按此即可進(jìn)入” + “</a>” + userinfo + “。”);

    // getURL
    // 如果參數(shù)未定義,默認(rèn)返回 www.yahoo.cn 網(wǎng)址
    // @param choice 選擇名稱
    // @return url 實(shí)際的URL
    function getURL(choice) {
    url = urlhash[choice];
    if (typeof(urlhash[choice]) == “undefined”)
    url = “www.yahoo.cn“;
    return url;
    }

    // 獲得hash列表的所有 keys
    // @param hash hash數(shù)組
    // @return keys 鍵名數(shù)據(jù)
    function array_keys(hash) {
    keys = [];
    for (key in hash)
    keys.push(key);
    return keys;
    }
    </script>

    posted @ 2012-12-20 11:28 askzs 閱讀(18371) | 評(píng)論 (1)編輯 收藏

    原文地址:http://www.cnblogs.com/Lewis/archive/2010/04/27/1722024.html

     

    關(guān)于JQuery上傳插件Uploadify使用詳解網(wǎng)上一大把,基本上內(nèi)容都一樣。我根據(jù)網(wǎng)上的步驟配置成功后,會(huì)報(bào)一些錯(cuò)誤,而我根據(jù)這些錯(cuò)誤去網(wǎng)上找解決方案,卻沒(méi)有相關(guān)資料,所以為了不讓更多的朋友走彎路,我把我遇到的一些問(wèn)題進(jìn)行匯總,也方便我自己以后查閱。

      什么是Uploadify

      Uploadify是JQuery的一個(gè)上傳插件,支持多文件上傳,實(shí)現(xiàn)的效果非常不錯(cuò),帶進(jìn)度顯示。

      官網(wǎng)提供的是PHP的DEMO,在這里我詳細(xì)介紹在Asp.net下的使用.

      下載

        官方下載

        官方文檔

        官方演示

      如何使用

      1 創(chuàng)建Web項(xiàng)目,命名為JQueryUploadDemo,從官網(wǎng)上下載最新的版本解壓后添加到項(xiàng)目中

      2 在項(xiàng)目中添加UploadHandler.ashx文件用來(lái)處理文件的上傳。

      3 在項(xiàng)目中添加UploadFile文件夾,用來(lái)存放上傳的文件。

      進(jìn)行完上面三步后項(xiàng)目的基本結(jié)構(gòu)如下圖:

      

      4 Default.aspx的html頁(yè)的代碼修改如下:

      

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
       
    <title>Uploadify</title>
       
    <link href="JS/jquery.uploadify-v2.1.0/example/css/default.css"
         rel
    ="stylesheet" type="text/css" />
       
    <link href="JS/jquery.uploadify-v2.1.0/uploadify.css"
         rel
    ="stylesheet" type="text/css" />

       
    <script type="text/javascript"
         src
    ="JS/jquery.uploadify-v2.1.0/jquery-1.3.2.min.js"></script>

       
    <script type="text/javascript"
         src
    ="JS/jquery.uploadify-v2.1.0/swfobject.js"></script>

       
    <script type="text/javascript"
       src
    ="JS/jquery.uploadify-v2.1.0/jquery.uploadify.v2.1.0.min.js"></script>

       
    <script type="text/javascript">
            $(document).ready(
    function()
            {
                $(
    "#uploadify").uploadify({
                   
    'uploader': 'JS/jquery.uploadify-v2.1.0/uploadify.swf',
                   
    'script': 'UploadHandler.ashx',
                   
    'cancelImg': 'JS/jquery.uploadify-v2.1.0/cancel.png',
                   
    'folder': 'UploadFile',
                   
    'queueID': 'fileQueue',
                   
    'auto': false,
                   
    'multi': true
                });
            }); 
       
    </script>

    </head>
    <body>
       
    <div id="fileQueue"></div>
       
    <input type="file" name="uploadify" id="uploadify" />
       
    <p>
         
    <a href="javascript:$('#uploadify').uploadifyUpload()">上傳</a>|
         
    <a href="javascript:$('#uploadify').uploadifyClearQueue()">取消上傳</a>
       
    </p>
    </body>
    </html>

      5  UploadHandler類(lèi)的ProcessRequest方法代碼如下:

      

    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType
    = "text/plain";  
        context.Response.Charset
    = "utf-8";  

        HttpPostedFile file
    = context.Request.Files["Filedata"];  
       
    string  uploadPath =
            HttpContext.Current.Server.MapPath(@context.Request[
    "folder"])+"\\"

       
    if (file != null
        { 
          
    if (!Directory.Exists(uploadPath)) 
           { 
               Directory.CreateDirectory(uploadPath); 
           }  
           file.SaveAs(uploadPath
    + file.FileName); 
           
    //下面這句代碼缺少的話,上傳成功后上傳隊(duì)列的顯示不會(huì)自動(dòng)消失
           context.Response.Write("1"); 
        }  
       
    else 
        {  
            context.Response.Write(
    "0");  
        } 
    }

      注意:這里一定要注意,一定要引用using System.IO;命名空間,我出錯(cuò)的原因也是在這里,網(wǎng)上的教程基本上都沒(méi)提到這一點(diǎn),所以有很多網(wǎng)友會(huì)遇到IOError的錯(cuò)誤。

    6 運(yùn)行后效果如下圖:

      

      7 選擇了兩個(gè)文件后,點(diǎn)擊上傳,就可以看到UploadFile文件夾中會(huì)增加這兩個(gè)文件。

      

      上面的代碼就簡(jiǎn)單實(shí)現(xiàn)了上傳的功能,依靠函數(shù)uploadify實(shí)現(xiàn),uploadify函數(shù)的參數(shù)為json格式,可以對(duì)json對(duì)象的key值的修改來(lái)進(jìn)行自定義的設(shè)置,如multi設(shè)置為true或false來(lái)控制是否可以進(jìn)行多文件上傳,下面就來(lái)介紹下這些key值的意思:

     

    uploader : uploadify.swf 文件的相對(duì)路徑,該swf文件是一個(gè)帶有文字BROWSE的按鈕,點(diǎn)擊后淡出打開(kāi)文件對(duì)話框,默認(rèn)值:uploadify.swf。
    script :   后臺(tái)處理程序的相對(duì)路徑 。默認(rèn)值:uploadify.php
    checkScript :用來(lái)判斷上傳選擇的文件在服務(wù)器是否存在的后臺(tái)處理程序的相對(duì)路徑
    fileDataName :設(shè)置一個(gè)名字,在服務(wù)器處理程序中根據(jù)該名字來(lái)取上傳文件的數(shù)據(jù)。默認(rèn)為Filedata
    method : 提交方式Post 或Get 默認(rèn)為Post
    scriptAccess :flash腳本文件的訪問(wèn)模式,如果在本地測(cè)試設(shè)置為always,默認(rèn)值:sameDomain 
    folder :  上傳文件存放的目錄 。
    queueID : 文件隊(duì)列的ID,該ID與存放文件隊(duì)列的div的ID一致。
    queueSizeLimit : 當(dāng)允許多文件生成時(shí),設(shè)置選擇文件的個(gè)數(shù),默認(rèn)值:999 。
    multi : 設(shè)置為true時(shí)可以上傳多個(gè)文件。
    auto : 設(shè)置為true當(dāng)選擇文件后就直接上傳了,為false需要點(diǎn)擊上傳按鈕才上傳 。
    fileDesc : 這個(gè)屬性值必須設(shè)置fileExt屬性后才有效,用來(lái)設(shè)置選擇文件對(duì)話框中的提示文本,如設(shè)置fileDesc為“請(qǐng)選擇rar doc pdf文件”,打開(kāi)文件選擇框效果如下圖:

      

    fileExt : 設(shè)置可以選擇的文件的類(lèi)型,格式如:'*.doc;*.pdf;*.rar' 。
    sizeLimit : 上傳文件的大小限制 。
    simUploadLimit : 允許同時(shí)上傳的個(gè)數(shù) 默認(rèn)值:1 。
    buttonText : 瀏覽按鈕的文本,默認(rèn)值:BROWSE 。
    buttonImg : 瀏覽按鈕的圖片的路徑 。
    hideButton : 設(shè)置為true則隱藏瀏覽按鈕的圖片 。
    rollover : 值為true和false,設(shè)置為true時(shí)當(dāng)鼠標(biāo)移到瀏覽按鈕上時(shí)有反轉(zhuǎn)效果。
    width : 設(shè)置瀏覽按鈕的寬度 ,默認(rèn)值:110。
    height : 設(shè)置瀏覽按鈕的高度 ,默認(rèn)值:30。
    wmode : 設(shè)置該項(xiàng)為transparent 可以使瀏覽按鈕的flash背景文件透明,并且flash文件會(huì)被置為頁(yè)面的最高層。 默認(rèn)值:opaque 。
    cancelImg :選擇文件到文件隊(duì)列中后的每一個(gè)文件上的關(guān)閉按鈕圖標(biāo),如下圖:

      

    上面介紹的key值的value都為字符串或是布爾類(lèi)型,比較簡(jiǎn)單,接下來(lái)要介紹的key值的value為一個(gè)函數(shù),可以在選擇文件、出錯(cuò)或其他一些操作的時(shí)候返回一些信息給用戶。

    onInit : 做一些初始化的工作。

    onSelect :選擇文件時(shí)觸發(fā),該函數(shù)有三個(gè)參數(shù)

    • event:事件對(duì)象。
    • queueID:文件的唯一標(biāo)識(shí),由6為隨機(jī)字符組成。
    • fileObj:選擇的文件對(duì)象,有name、size、creationDate、modificationDate、type 5個(gè)屬性。

    代碼如下:

      

    $(document).ready(function()
    {
        $(
    "#uploadify").uploadify({
           
    'uploader': 'JS/jquery.uploadify-v2.1.0/uploadify.swf',
           
    'script': 'UploadHandler.ashx',
           
    'cancelImg': 'JS/jquery.uploadify-v2.1.0/cancel.png',
           
    'folder': 'UploadFile',
           
    'queueID': 'fileQueue',
           
    'auto': false,
           
    'multi': true,
           
    'onInit':function(){alert("1");},
           
    'onSelect': function(e, queueId, fileObj)
            {
                alert(
    "唯一標(biāo)識(shí):" + queueId + "\r\n" +
                     
    "文件名:" + fileObj.name + "\r\n" +
                     
    "文件大?。?/span>" + fileObj.size + "\r\n" +
                     
    "創(chuàng)建時(shí)間:" + fileObj.creationDate + "\r\n" +
                     
    "最后修改時(shí)間:" + fileObj.modificationDate + "\r\n" +
                     
    "文件類(lèi)型:" + fileObj.type
                );

            }
        });
    }); 

     


    當(dāng)選擇一個(gè)文件后彈出的消息如下圖:

    onSelectOnce :在單文件或多文件上傳時(shí),選擇文件時(shí)觸發(fā)。該函數(shù)有兩個(gè)參數(shù)event,data,data對(duì)象有以下幾個(gè)屬性:

    fileCount:選擇文件的總數(shù)。
    filesSelected:同時(shí)選擇文件的個(gè)數(shù),如果一次選擇了3個(gè)文件該屬性值為3。
    filesReplaced:如果文件隊(duì)列中已經(jīng)存在A和B兩個(gè)文件,再次選擇文件時(shí)又選擇了A和B,該屬性值為2。
    allBytesTotal:所有選擇的文件的總大小。
     

    onCancel : 當(dāng)點(diǎn)擊文件隊(duì)列中文件的關(guān)閉按鈕或點(diǎn)擊取消上傳時(shí)觸發(fā)。該函數(shù)有event、queueId、fileObj、data四個(gè)參數(shù),前三個(gè)參數(shù)同onSelect 中的三個(gè)參數(shù),data對(duì)象有兩個(gè)屬性fileCount和allBytesTotal。

    fileCount:取消一個(gè)文件后,文件隊(duì)列中剩余文件的個(gè)數(shù)。
    allBytesTotal:取消一個(gè)文件后,文件隊(duì)列中剩余文件的大小。
     

    onClearQueue :當(dāng)調(diào)用函數(shù)fileUploadClearQueue時(shí)觸發(fā)。有event和data兩個(gè)參數(shù),同onCancel 中的兩個(gè)對(duì)應(yīng)參數(shù)。

    onQueueFull :當(dāng)設(shè)置了queueSizeLimit并且選擇的文件個(gè)數(shù)超出了queueSizeLimit的值時(shí)觸發(fā)。該函數(shù)有兩個(gè)參數(shù)event和queueSizeLimit。

    onError :當(dāng)上傳過(guò)程中發(fā)生錯(cuò)誤時(shí)觸發(fā)。該函數(shù)有event、queueId、fileObj、errorObj四個(gè)參數(shù),其中前三個(gè)參數(shù)同上,errorObj對(duì)象有type和info兩個(gè)屬性。

    type:錯(cuò)誤的類(lèi)型,有三種‘HTTP’, ‘IO’, or ‘Security’
    info:錯(cuò)誤的描述
     

    onOpen :點(diǎn)擊上傳時(shí)觸發(fā),如果auto設(shè)置為true則是選擇文件時(shí)觸發(fā),如果有多個(gè)文件上傳則遍歷整個(gè)文件隊(duì)列。該函數(shù)有event、queueId、fileObj三個(gè)參數(shù),參數(shù)的解釋同上。

    onProgress :點(diǎn)擊上傳時(shí)觸發(fā),如果auto設(shè)置為true則是選擇文件時(shí)觸發(fā),如果有多個(gè)文件上傳則遍歷整個(gè)文件隊(duì)列,在onOpen之后觸發(fā)。該函數(shù)有event、queueId、fileObj、data四個(gè)參數(shù),前三個(gè)參數(shù)的解釋同上。data對(duì)象有四個(gè)屬性percentage、bytesLoaded、allBytesLoaded、speed:

    percentage:當(dāng)前完成的百分比
    bytesLoaded:當(dāng)前上傳的大小
    allBytesLoaded:文件隊(duì)列中已經(jīng)上傳完的大小
    speed:上傳速率 kb/s
     

    onComplete:文件上傳完成后觸發(fā)。該函數(shù)有四個(gè)參數(shù)event、queueId、fileObj、response、data五個(gè)參數(shù),前三個(gè)參數(shù)同上。response為后臺(tái)處理程序返回的值,在上面的例子中為1或0,data有兩個(gè)屬性fileCount和speed

    fileCount:剩余沒(méi)有上傳完成的文件的個(gè)數(shù)。
    speed:文件上傳的平均速率 kb/s
    注:fileObj對(duì)象和上面講到的有些不太一樣,onComplete 的fileObj對(duì)象有個(gè)filePath屬性可以取出上傳文件的路徑。

     

    onAllComplete:文件隊(duì)列中所有的文件上傳完成后觸發(fā)。該函數(shù)有event和data兩個(gè)參數(shù),data有四個(gè)屬性,分別為:

    filesUploaded :上傳的所有文件個(gè)數(shù)。
    errors :出現(xiàn)錯(cuò)誤的個(gè)數(shù)。
    allBytesLoaded :所有上傳文件的總大小。
    speed :平均上傳速率 kb/s
     

    相關(guān)函數(shù)介紹

    在上面的例子中已經(jīng)用了uploadifyUpload和uploadifyClearQueue兩個(gè)函數(shù),除此之外還有幾個(gè)函數(shù):

    uploadifySettings:可以動(dòng)態(tài)修改上面介紹的那些key值,如下面代碼

      $('#uploadify').uploadifySettings('folder','JS'); 

    如果上傳按鈕的事件寫(xiě)成下面這樣,文件將會(huì)上傳到uploadifySettings定義的目錄中

    <a href="javascript:$('#uploadify').uploadifySettings('folder','JS');$('#uploadify').uploadifyUpload()">上傳</a>

      uploadifyCancel:該函數(shù)接受一個(gè)queueID作為參數(shù),可以取消文件隊(duì)列中指定queueID的文件。

      
      $('#uploadify').uploadifyCancel(id); 

     

      好了,所有的配置都完成了。下面說(shuō)說(shuō)我遇到的一些問(wèn)題。 span style="font-size: 18pt;"> 可能遇到的問(wèn)題   1.我剛開(kāi)始配置完成后,并不能正常工作 ,flash(uploadify.swf' )沒(méi)有加載。后來(lái)我查看jquery.uploadify.v2.1.0.js發(fā)現(xiàn)該插件是利用swfobject.js動(dòng)態(tài)創(chuàng)建的FLASH,后來(lái)我單獨(dú)做試驗(yàn)還是不能顯示flash,無(wú)耐之下重啟電腦后就可以了。暈倒~~~  2.FLASH終于加載進(jìn)來(lái)了,但上傳又失敗了。報(bào)IOError,如圖:  

      

    百思不得其解,翻遍了各大網(wǎng)絡(luò),終于在國(guó)外的一網(wǎng)站看到了這么一句using System.IO; 添加之豁然開(kāi)朗??!

    暫時(shí)還沒(méi)有遇到其它問(wèn)題,后續(xù)發(fā)現(xiàn)問(wèn)題再加。

    posted @ 2012-11-20 11:41 askzs 閱讀(1159) | 評(píng)論 (0)編輯 收藏

    ThickBox 是基于 jQuery 用 JavaScript 編寫(xiě)的網(wǎng)頁(yè)UI對(duì)話窗口小部件. 它可以用來(lái)展示單一圖片, 若干圖片, 內(nèi)嵌的內(nèi)容, iframed的內(nèi)容, 或以 AJAX 的混合 modal 提供的內(nèi)容.

    特性:

    • ThickBox 是用超輕量級(jí)的 jQuery 庫(kù) 編寫(xiě)的. 壓縮過(guò) jQuery 庫(kù)只15k, 未壓縮過(guò)的有39k.
    • ThickBox 的 JavaScript 代碼和 CSS 文件只占12k. 所以壓縮過(guò)的 jQuery 代碼和 ThickBox 總共只有27k.
    • ThickBox 能重新調(diào)整大于瀏覽器窗口的圖片.
    • ThickBox 的多功能性包括 (圖片, iframed 的內(nèi)容, 內(nèi)嵌的內(nèi)容, 和 AJAX 的內(nèi)容).
    • ThickBox 能隱藏 Windows IE 6 里的元素.
    • ThickBox 能在使用者滾動(dòng)頁(yè)面或改變?yōu)g覽器窗口大小的同時(shí)始終保持居中. 點(diǎn)擊圖片, 覆蓋層, 或關(guān)閉鏈接能移除 ThickBox.
    • ThickBox 的創(chuàng)作者決定動(dòng)畫(huà)應(yīng)該因人而異, 所以 ThickBox 不再使用動(dòng)畫(huà)了. 這是特性嗎? 哦, 有人說(shuō)是呀.

    下載

    posted @ 2012-08-13 11:06 askzs 閱讀(299) | 評(píng)論 (0)編輯 收藏

    在項(xiàng)目中,需要用到打印,最早的是使用js調(diào)用本地打印,效果不好,樣式等不好控制,容易出錯(cuò),有時(shí)候?yàn)g覽器不兼容造成不能打印,后來(lái)用報(bào)表,生成破地方格式的然后打印,兼容性強(qiáng),穩(wěn)定,比較好用,基本上沒(méi)有什么問(wèn)題,但是開(kāi)發(fā)過(guò)程慢,報(bào)表不好畫(huà),action不好控制,總之,開(kāi)發(fā)過(guò)程比較痛苦,而且樣式變的話報(bào)表需要重新畫(huà),不好修改,后來(lái)發(fā)現(xiàn)了 lodop,是個(gè)瀏覽器的插件,需要客戶安裝,安裝后使用方便,打印效果不錯(cuò),還可以讓用戶自己調(diào)試打印模式,而且支持的打印種類(lèi)多,可以打印背景圖片,套表格式等,就是很方便就是了,安裝也方便,下面是詳細(xì)的介紹說(shuō)明。
    http://mtsoftware.v053.gokao.net/samples/PrintSampIndex.html

    最新版本及其技術(shù)手冊(cè)可從如下地址下載:
    http://mtsoftware.v053.gokao.net/download.html
    http://mt.runon.cn/download.html 


    posted @ 2012-08-13 09:35 askzs 閱讀(1342) | 評(píng)論 (4)編輯 收藏

    在Java中有時(shí)候需要使程序暫停一點(diǎn)時(shí)間,稱為延時(shí)。普通延時(shí)用Thread.sleep(int)方法,這很簡(jiǎn)單。它將當(dāng)前線程掛起指定的毫秒數(shù)。如

    Java 代碼復(fù)制內(nèi)容到剪貼板
    1. try
    2. {
    3. Thread.currentThread().sleep(1000);//毫秒
    4. }
    5. catch(Exception e){}

    在這里需要解釋一下線程沉睡的時(shí)間。sleep()方法并不能夠讓程序"嚴(yán)格"的沉睡指定的時(shí)間。例如當(dāng)使用5000作為sleep()方法的參數(shù)時(shí),線 程可能在實(shí)際被掛起5000.001毫秒后才會(huì)繼續(xù)運(yùn)行。當(dāng)然,對(duì)于一般的應(yīng)用程序來(lái)說(shuō),sleep()方法對(duì)時(shí)間控制的精度足夠了。

    但是如果要使用精確延時(shí),最好使用Timer類(lèi):

    Java 代碼復(fù)制內(nèi)容到剪貼板
    1. Timer timer=new Timer();//實(shí)例化Timer類(lèi)
    2. timer.schedule(new TimerTask(){
    3. public void run(){
    4. System.out.println("退出");
    5. this.cancel();}},500);//五百毫秒

    這種延時(shí)比sleep精確。上述延時(shí)方法只運(yùn)行一次,
    如果需要運(yùn)行多次, 使用timer.schedule(new MyTask(), 1000, 2000); 則每間隔2秒執(zhí)行MyTask()

    posted @ 2012-06-05 11:35 askzs 閱讀(355) | 評(píng)論 (0)編輯 收藏

    本課題參考自《Spring in action》。并非應(yīng)用系統(tǒng)中發(fā)生的所有事情都是由用戶的動(dòng)作引起的。有時(shí)候,系統(tǒng)自己也需要發(fā)起一些動(dòng)作。例如,集抄系統(tǒng)每天早上六點(diǎn)把抄表數(shù)據(jù)傳送 給營(yíng)銷(xiāo)系統(tǒng)。我們有兩種選擇:或者是每天由用戶手動(dòng)出發(fā)任務(wù),或者讓?xiě)?yīng)用系統(tǒng)中按照預(yù)定的計(jì)劃自動(dòng)執(zhí)行任務(wù)。 
    在Spring中有兩種流行配置:Java的Timer類(lèi)和OpenSymphony的Quartz來(lái)執(zhí)行調(diào)度任務(wù)。下面以給商丘做的接口集抄900到中間庫(kù)的日凍結(jié)數(shù)據(jù)傳輸為例: 

    1. Java Timer調(diào)度器 
    首先定義一個(gè)定時(shí)器任務(wù),繼承java.util.TimerTask類(lèi)實(shí)現(xiàn)run方法 
    import java.util.TimerTask; 
    import xj.service.IJdbc1Service; 
    import xj.service.IJdbc2Service; 
    public class DayDataTimerTask extends TimerTask{ 
    private IJdbc2Service jdbc2Service=null; 
    private IJdbc1Service jdbc1Service=null; 
    public void run(){ 
    SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 
    System.out.println("日凍結(jié)轉(zhuǎn)接任務(wù)開(kāi)始時(shí)間:"+df.format(Calendar.getInstance().getTime())); 
    System.out.println("日凍結(jié)轉(zhuǎn)接任務(wù)結(jié)束時(shí)間:"+df.format(Calendar.getInstance().getTime())); 


    //通過(guò)set方法獲取service服務(wù),如果沒(méi)有該方法,則為null 
    public void setJdbc2Service(IJdbc2Service jdbc2Service) { 
    this.jdbc2Service = jdbc2Service; 


    public void setJdbc1Service(IJdbc1Service jdbc1Service) { 
    this.jdbc1Service = jdbc1Service; 


    Run()方法定義了當(dāng)任務(wù)運(yùn)行時(shí)該做什么。jdbc1Service,jdbc2Service通過(guò)依賴注入的方式提供給DayDataTimerTask。如果該任務(wù)中沒(méi)有service服務(wù)的set方法,則取到的該service服務(wù)為null。 
    其次,在Spring配置文件中聲明 dayDataTimerTask: 
    <!-- 聲明定時(shí)器任務(wù) --> 
    <bean id="dayDataTimerJob" class="xj.action.DayDataTimerTask"> 
    <property name="jdbc1Service"> 
    <ref bean="jdbc1Service"/> 
    </property> 
    <property name="jdbc2Service"> 
    <ref bean="jdbc2Service"/> 
    </property> 
    </bean> 
    該聲明將DayDataTimerTask放到應(yīng)用上下文中,并在jdbc1Service、jdbc2Service屬性中分別裝配jdbc1Service、jdbc2Service。在調(diào)度它之前,它不會(huì)做任何事情。 
    <!-- 調(diào)度定時(shí)器任務(wù) --> 
    <bean id="scheduledDayDataTimerJob" class="org.springframework.scheduling.timer.ScheduledTimerTask"> 
    <property name="timerTask"> 
    <ref bean="dayDataTimerJob"/> 
    </property> 
    <property name="delay"> 
    <value>3000</value> 
    </property> 
    <property name="period"> 
    <value>864000000</value> 
    </property> 
    </bean> 
    屬性timerTask告訴ScheduledTimerTask運(yùn)行哪個(gè)TimerTask。再次,該屬性裝配了指向 scheduledDayDataTimerJob的一個(gè)引用,它就是DayDataTimerTask。屬性period告訴 ScheduledTimerTask以怎樣的頻度調(diào)用TimerTask的run()方法。該屬性以毫秒作為單位,它被設(shè)置為864000000,指定 這個(gè)任務(wù)應(yīng)該每24小時(shí)運(yùn)行一次。屬性delay允許你指定當(dāng)任務(wù)第一次運(yùn)行之前應(yīng)該等待多久。在此指定DayDataTimerTask的第一次運(yùn)行相 對(duì)于應(yīng)用程序的啟動(dòng)時(shí)間延遲3秒鐘。 
    <!-- 啟動(dòng)定時(shí)器 --> 
    <bean class="org.springframework.scheduling.timer.TimerFactoryBean"> 
    <property name="scheduledTimerTasks"> 
    <list> 
    <ref bean="scheduledDayDataTimerJob"/> 
    </list> 
    </property> 
    </bean> 
    Spring的TimerFactoryBean負(fù)責(zé)啟動(dòng)定時(shí)任務(wù)。屬性scheduledTimerTasks要求一個(gè)需要啟動(dòng)的定時(shí)器任務(wù)的列表。在此只包含一個(gè)指向scheduledDayDataTimerJob的引用。 
        Java Timer只能指定任務(wù)執(zhí)行的頻度,但無(wú)法精確指定它何時(shí)運(yùn)行,這是它的一個(gè)局限性。要想精確指定任務(wù)的啟動(dòng)時(shí)間,就需要使用Quartz[kw?:ts]調(diào)度器。 

    2.Quartz調(diào)度器 
    Quartz調(diào)度器不僅可以定義每隔多少毫秒執(zhí)行一個(gè)工作,還允許你調(diào)度一個(gè)工作在某個(gè)特定的時(shí)間或日期執(zhí)行。 
    首先創(chuàng)建一個(gè)工作,繼承QuartzJobBean類(lèi)實(shí)現(xiàn)executeInternal方法 
    import org.quartz.JobExecutionContext; 
    import org.quartz.JobExecutionException; 
    import org.springframework.dao.DataIntegrityViolationException; 
    import org.springframework.scheduling.quartz.QuartzJobBean; 

    import xj.service.IJdbc1Service; 
    import xj.service.IJdbc2Service; 
    public class DayDataQuartzTask extends QuartzJobBean{ 
    private IJdbc2Service jdbc2Service=null; 
    private IJdbc1Service jdbc1Service=null; 
    protected void executeInternal(JobExecutionContext context) throws JobExecutionException{ 
    SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 
    System.out.println("日凍結(jié)轉(zhuǎn)接任務(wù)開(kāi)始時(shí)間:"+df.format(Calendar.getInstance().getTime())); 
    System.out.println("日凍結(jié)轉(zhuǎn)接任務(wù)結(jié)束時(shí)間:"+df.format(Calendar.getInstance().getTime())); 


    //通過(guò)set方法獲取service服務(wù),如果沒(méi)有該方法,則為null 
    public void setJdbc2Service(IJdbc2Service jdbc2Service) { 
    this.jdbc2Service = jdbc2Service; 


    public void setJdbc1Service(IJdbc1Service jdbc1Service) { 
    this.jdbc1Service = jdbc1Service; 




    在Spring配置文件中按照以下方式聲明這個(gè)工作: 
    <!-- 定時(shí)啟動(dòng)任務(wù) Quartz--> 
    <!—聲明工作--> 
    <bean id="dayDataJob" class="org.springframework.scheduling.quartz.JobDetailBean"> 
    <property name="jobClass"> 
    <value>xj.action.DayDataQuartzTask</value> 
    </property> 
    <property name="jobDataAsMap"> 
    <map> 
    <entry key="jdbc1Service"> 
    <ref bean="jdbc1Service"/> 
    </entry> 
    <entry key="jdbc2Service"> 
    <ref bean="jdbc2Service"/> 
    </entry> 
    </map> 
    </property> 
    </bean> 
    Quartz的org.quartz.Trigger類(lèi)描述了何時(shí)及以怎樣的頻度運(yùn)行一個(gè)Quartz工作。Spring提供了兩個(gè)觸發(fā)器 SimpleTriggerBean和CronTriggerBean。SimpleTriggerBean與scheduledTimerTasks類(lèi) 似。指定工作的執(zhí)行頻度,模仿scheduledTimerTasks配置。 
    <!-- 調(diào)度Simple工作 --> 
    <bean id="simpleDayDataJobTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean"> 
    <property name="jobDetail"> 
    <ref bean="dayDataJob"/> 
    </property> 
    <property name="startDelay"> 
    <value>1000</value> 
    </property> 
    <property name="repeatInterval"> 
    <value>86400000</value> 
    </property> 
    </bean> 
    <!—調(diào)度cron工作--> 
    <bean id="dayDataJobTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean"> 
    <property name="jobDetail"> 
    <ref bean="dayDataJob"/> 
    </property> 
    <property name="cronExpression"> 
    <value>0 30 2 * * ?</value> 
    </property> 
    </bean> 
    一個(gè)cron表達(dá)式有6個(gè)或7個(gè)由空格分隔的時(shí)間元素。從左至右,這些元素的定義如下:1、秒(0-59);2、分(0-59);3、小時(shí) (0-23);4、月份中的日期(1-31);5、月份(1-12或JAN-DEC);6、星期中的日期(1-7或SUN-SAT);7、年份 (1970-2099)。 
    每一個(gè)元素都可以顯式地規(guī)定一個(gè)值(如6),一個(gè)區(qū)間(如9-12),一個(gè)列表(如9,11,13)或一個(gè)通配符(如*)。“月份中的日期”和“星期中的日期”這兩個(gè)元素互斥,應(yīng)該通過(guò)設(shè)置一個(gè)問(wèn)號(hào)(?)來(lái)表明你不想設(shè)置的那個(gè)字段。

    corn表達(dá)式API具體見(jiàn) 

    http://www.quartz-scheduler.org/documentation/quartz-1.x/tutorials/crontrigger

    我們?cè)诖硕x該任務(wù)在每天凌晨?jī)牲c(diǎn)半開(kāi)始啟動(dòng)。 
    <!—啟動(dòng)工作--> 
    <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> 
    <property name="triggers"> 
    <list> 
    <ref bean="simpleDayDataJobTrigger"/> 
    <ref bean="dayDataJobTrigger"/> 
    </list> 
    </property> 
    </bean> 
    屬性triggers接受一組觸發(fā)器,在此只裝配包含simpleDayDataJobTrigger bea和dayDataJobTrigger bean的一個(gè)引用列表。

    posted @ 2012-05-30 13:02 askzs 閱讀(2736) | 評(píng)論 (0)編輯 收藏

         摘要: Spring配置文件中關(guān)于事務(wù)配置總是由三個(gè)組成部分,分別是DataSource、TransactionManager和代理機(jī)制這三部分,無(wú)論哪種配置方式,一般變化的只是代理機(jī)制這部分。   DataSource、TransactionManager這兩部分只是會(huì)根據(jù)數(shù)據(jù)訪問(wèn)方式有所變化,比如使用Hibernate進(jìn)行數(shù)據(jù)訪問(wèn)時(shí),DataSource實(shí)際為SessionFactory,Tran...  閱讀全文
    posted @ 2012-05-30 10:07 askzs 閱讀(365) | 評(píng)論 (0)編輯 收藏

    mport java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.nio.MappedByteBuffer;
    import java.nio.channels.FileChannel;


    public class MbbDemo {
     
     public static  void main(String []args)throws Exception
     {
      File file=new File("d://a.txt");
      FileInputStream fis=new FileInputStream(file);
         FileOutputStream fos=new FileOutputStream("d://acopy.txt");
         FileChannel fChannel=fis.getChannel();
         FileChannel out=fos.getChannel();
         MappedByteBuffer mbb=fChannel.map(FileChannel.MapMode.READ_ONLY, 0,file.length());
         out.write(mbb);
         if(fis!=null)fis.close();
         if(fos!=null)fos.close();
      
      
     }

    }

    posted @ 2012-05-25 14:11 askzs 閱讀(742) | 評(píng)論 (0)編輯 收藏

    轉(zhuǎn)載自 http://www.ibm.com/developerworks/cn/java/joy-down/

    斷點(diǎn)續(xù)傳的原理

    其實(shí)斷點(diǎn)續(xù)傳的原理很簡(jiǎn)單,就是在 Http 的請(qǐng)求上和一般的下載有所不同而已。
    打個(gè)比方,瀏覽器請(qǐng)求服務(wù)器上的一個(gè)文時(shí),所發(fā)出的請(qǐng)求如下:
    假設(shè)服務(wù)器域名為 wwww.sjtu.edu.cn,文件名為 down.zip。
    GET /down.zip HTTP/1.1
    Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-
    excel, application/msword, application/vnd.ms-powerpoint, */*
    Accept-Language: zh-cn
    Accept-Encoding: gzip, deflate
    User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)
    Connection: Keep-Alive

    服務(wù)器收到請(qǐng)求后,按要求尋找請(qǐng)求的文件,提取文件的信息,然后返回給瀏覽器,返回信息如下:

    200
    Content-Length=106786028
    Accept-Ranges=bytes
    Date=Mon, 30 Apr 2001 12:56:11 GMT
    ETag=W/"02ca57e173c11:95b"
    Content-Type=application/octet-stream
    Server=Microsoft-IIS/5.0
    Last-Modified=Mon, 30 Apr 2001 12:56:11 GMT

    所謂斷點(diǎn)續(xù)傳,也就是要從文件已經(jīng)下載的地方開(kāi)始繼續(xù)下載。所以在客戶端瀏覽器傳給 Web 服務(wù)器的時(shí)候要多加一條信息 -- 從哪里開(kāi)始。
    下面是用自己編的一個(gè)"瀏覽器"來(lái)傳遞請(qǐng)求信息給 Web 服務(wù)器,要求從 2000070 字節(jié)開(kāi)始。
    GET /down.zip HTTP/1.0
    User-Agent: NetFox
    RANGE: bytes=2000070-
    Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2

    仔細(xì)看一下就會(huì)發(fā)現(xiàn)多了一行 RANGE: bytes=2000070-
    這一行的意思就是告訴服務(wù)器 down.zip 這個(gè)文件從 2000070 字節(jié)開(kāi)始傳,前面的字節(jié)不用傳了。
    服務(wù)器收到這個(gè)請(qǐng)求以后,返回的信息如下:
    206
    Content-Length=106786028
    Content-Range=bytes 2000070-106786027/106786028
    Date=Mon, 30 Apr 2001 12:55:20 GMT
    ETag=W/"02ca57e173c11:95b"
    Content-Type=application/octet-stream
    Server=Microsoft-IIS/5.0
    Last-Modified=Mon, 30 Apr 2001 12:55:20 GMT

    和前面服務(wù)器返回的信息比較一下,就會(huì)發(fā)現(xiàn)增加了一行:
    Content-Range=bytes 2000070-106786027/106786028
    返回的代碼也改為 206 了,而不再是 200 了。

    知道了以上原理,就可以進(jìn)行斷點(diǎn)續(xù)傳的編程了。


    Java 實(shí)現(xiàn)斷點(diǎn)續(xù)傳的關(guān)鍵幾點(diǎn)

    1. (1) 用什么方法實(shí)現(xiàn)提交 RANGE: bytes=2000070-。
      當(dāng)然用最原始的 Socket 是肯定能完成的,不過(guò)那樣太費(fèi)事了,其實(shí) Java 的 net 包中提供了這種功能。代碼如下:

      URL url = new URL("http://www.sjtu.edu.cn/down.zip");
      HttpURLConnection httpConnection = (HttpURLConnection)url.openConnection();

      // 設(shè)置 User-Agent
      httpConnection.setRequestProperty("User-Agent","NetFox");
      // 設(shè)置斷點(diǎn)續(xù)傳的開(kāi)始位置
      httpConnection.setRequestProperty("RANGE","bytes=2000070");
      // 獲得輸入流
      InputStream input = httpConnection.getInputStream();

      從輸入流中取出的字節(jié)流就是 down.zip 文件從 2000070 開(kāi)始的字節(jié)流。大家看,其實(shí)斷點(diǎn)續(xù)傳用 Java 實(shí)現(xiàn)起來(lái)還是很簡(jiǎn)單的吧。接下來(lái)要做的事就是怎么保存獲得的流到文件中去了。

    2. 保存文件采用的方法。
      我采用的是 IO 包中的 RandAccessFile 類(lèi)。
      操作相當(dāng)簡(jiǎn)單,假設(shè)從 2000070 處開(kāi)始保存文件,代碼如下:
      RandomAccess oSavedFile = new RandomAccessFile("down.zip","rw");
      long nPos = 2000070;
      // 定位文件指針到 nPos 位置
      oSavedFile.seek(nPos);
      byte[] b = new byte[1024];
      int nRead;
      // 從輸入流中讀入字節(jié)流,然后寫(xiě)到文件中
      while((nRead=input.read(b,0,1024)) > 0)
      {
      oSavedFile.write(b,0,nRead);
      }

    怎么樣,也很簡(jiǎn)單吧。接下來(lái)要做的就是整合成一個(gè)完整的程序了。包括一系列的線程控制等等。


    斷點(diǎn)續(xù)傳內(nèi)核的實(shí)現(xiàn)

    主要用了 6 個(gè)類(lèi),包括一個(gè)測(cè)試類(lèi)。
    SiteFileFetch.java 負(fù)責(zé)整個(gè)文件的抓取,控制內(nèi)部線程 (FileSplitterFetch 類(lèi) )。
    FileSplitterFetch.java 負(fù)責(zé)部分文件的抓取。
    FileAccess.java 負(fù)責(zé)文件的存儲(chǔ)。
    SiteInfoBean.java 要抓取的文件的信息,如文件保存的目錄,名字,抓取文件的 URL 等。
    Utility.java 工具類(lèi),放一些簡(jiǎn)單的方法。
    TestMethod.java 測(cè)試類(lèi)。

    下面是源程序:

    /* 
     /*
     * SiteFileFetch.java 
     */ 
     package NetFox; 
     import java.io.*; 
     import java.net.*; 
     public class SiteFileFetch extends Thread { 
     SiteInfoBean siteInfoBean = null; // 文件信息 Bean 
     long[] nStartPos; // 開(kāi)始位置
     long[] nEndPos; // 結(jié)束位置
     FileSplitterFetch[] fileSplitterFetch; // 子線程對(duì)象
     long nFileLength; // 文件長(zhǎng)度
     boolean bFirst = true; // 是否第一次取文件
     boolean bStop = false; // 停止標(biāo)志
     File tmpFile; // 文件下載的臨時(shí)信息
     DataOutputStream output; // 輸出到文件的輸出流
     public SiteFileFetch(SiteInfoBean bean) throws IOException 
     { 
     siteInfoBean = bean; 
     //tmpFile = File.createTempFile ("zhong","1111",new File(bean.getSFilePath())); 
     tmpFile = new File(bean.getSFilePath()+File.separator + bean.getSFileName()+".info");
     if(tmpFile.exists ()) 
     { 
     bFirst = false; 
     read_nPos(); 
     } 
     else 
     { 
     nStartPos = new long[bean.getNSplitter()]; 
     nEndPos = new long[bean.getNSplitter()]; 
     } 
     } 
     public void run() 
     { 
     // 獲得文件長(zhǎng)度
     // 分割文件
     // 實(shí)例 FileSplitterFetch 
     // 啟動(dòng) FileSplitterFetch 線程
     // 等待子線程返回
     try{ 
     if(bFirst) 
     { 
     nFileLength = getFileSize(); 
     if(nFileLength == -1) 
     { 
     System.err.println("File Length is not known!"); 
     } 
     else if(nFileLength == -2) 
     { 
     System.err.println("File is not access!"); 
     } 
     else 
     { 
     for(int i=0;i<nStartPos.length;i++) 
     { 
     nStartPos[i] = (long)(i*(nFileLength/nStartPos.length)); 
     } 
     for(int i=0;i<nEndPos.length-1;i++) 
     { 
     nEndPos[i] = nStartPos[i+1]; 
     } 
     nEndPos[nEndPos.length-1] = nFileLength; 
     } 
     } 
     // 啟動(dòng)子線程
     fileSplitterFetch = new FileSplitterFetch[nStartPos.length]; 
     for(int i=0;i<nStartPos.length;i++) 
     { 
     fileSplitterFetch[i] = new FileSplitterFetch(siteInfoBean.getSSiteURL(), 
     siteInfoBean.getSFilePath() + File.separator + siteInfoBean.getSFileName(), 
     nStartPos[i],nEndPos[i],i); 
     Utility.log("Thread " + i + " , nStartPos = " + nStartPos[i] + ", nEndPos = " 
     + nEndPos[i]); 
     fileSplitterFetch[i].start(); 
     } 
     // fileSplitterFetch[nPos.length-1] = new FileSplitterFetch(siteInfoBean.getSSiteURL(),
     siteInfoBean.getSFilePath() + File.separator 
     + siteInfoBean.getSFileName(),nPos[nPos.length-1],nFileLength,nPos.length-1); 
     // Utility.log("Thread " +(nPos.length-1) + ",nStartPos = "+nPos[nPos.length-1]+",
     nEndPos = " + nFileLength); 
     // fileSplitterFetch[nPos.length-1].start(); 
     // 等待子線程結(jié)束
     //int count = 0; 
     // 是否結(jié)束 while 循環(huán)
     boolean breakWhile = false; 
     while(!bStop) 
     { 
     write_nPos(); 
     Utility.sleep(500); 
     breakWhile = true; 
     for(int i=0;i<nStartPos.length;i++) 
     { 
     if(!fileSplitterFetch[i].bDownOver) 
     { 
     breakWhile = false; 
     break; 
     } 
     } 
     if(breakWhile) 
     break; 
     //count++; 
     //if(count>4) 
     // siteStop(); 
     } 
     System.err.println("文件下載結(jié)束!"); 
     } 
     catch(Exception e){e.printStackTrace ();} 
     } 
     // 獲得文件長(zhǎng)度
     public long getFileSize() 
     { 
     int nFileLength = -1; 
     try{ 
     URL url = new URL(siteInfoBean.getSSiteURL()); 
     HttpURLConnection httpConnection = (HttpURLConnection)url.openConnection ();
     httpConnection.setRequestProperty("User-Agent","NetFox"); 
     int responseCode=httpConnection.getResponseCode(); 
     if(responseCode>=400) 
     { 
     processErrorCode(responseCode); 
     return -2; //-2 represent access is error 
     } 
     String sHeader; 
     for(int i=1;;i++) 
     { 
     //DataInputStream in = new DataInputStream(httpConnection.getInputStream ()); 
     //Utility.log(in.readLine()); 
     sHeader=httpConnection.getHeaderFieldKey(i); 
     if(sHeader!=null) 
     { 
     if(sHeader.equals("Content-Length")) 
     { 
     nFileLength = Integer.parseInt(httpConnection.getHeaderField(sHeader)); 
     break; 
     } 
     } 
     else 
     break; 
     } 
     } 
     catch(IOException e){e.printStackTrace ();} 
     catch(Exception e){e.printStackTrace ();} 
     Utility.log(nFileLength); 
     return nFileLength; 
     } 
     // 保存下載信息(文件指針位置)
     private void write_nPos() 
     { 
     try{ 
     output = new DataOutputStream(new FileOutputStream(tmpFile)); 
     output.writeInt(nStartPos.length); 
     for(int i=0;i<nStartPos.length;i++) 
     { 
     // output.writeLong(nPos[i]); 
     output.writeLong(fileSplitterFetch[i].nStartPos); 
     output.writeLong(fileSplitterFetch[i].nEndPos); 
     } 
     output.close(); 
     } 
     catch(IOException e){e.printStackTrace ();} 
     catch(Exception e){e.printStackTrace ();} 
     } 
     // 讀取保存的下載信息(文件指針位置)
     private void read_nPos() 
     { 
     try{ 
     DataInputStream input = new DataInputStream(new FileInputStream(tmpFile)); 
     int nCount = input.readInt(); 
     nStartPos = new long[nCount]; 
     nEndPos = new long[nCount]; 
     for(int i=0;i<nStartPos.length;i++) 
     { 
     nStartPos[i] = input.readLong(); 
     nEndPos[i] = input.readLong(); 
     } 
     input.close(); 
     } 
     catch(IOException e){e.printStackTrace ();} 
     catch(Exception e){e.printStackTrace ();} 
     } 
     private void processErrorCode(int nErrorCode) 
     { 
     System.err.println("Error Code : " + nErrorCode); 
     } 
     // 停止文件下載
     public void siteStop() 
     { 
     bStop = true; 
     for(int i=0;i<nStartPos.length;i++) 
     fileSplitterFetch[i].splitterStop(); 
     } 
     } 
     

     /* 
     **FileSplitterFetch.java 
     */ 
     package NetFox; 
     import java.io.*; 
     import java.net.*; 
     public class FileSplitterFetch extends Thread { 
     String sURL; //File URL 
     long nStartPos; //File Snippet Start Position 
     long nEndPos; //File Snippet End Position 
     int nThreadID; //Thread's ID 
     boolean bDownOver = false; //Downing is over 
     boolean bStop = false; //Stop identical 
     FileAccessI fileAccessI = null; //File Access interface 
     public FileSplitterFetch(String sURL,String sName,long nStart,long nEnd,int id)
     throws IOException 
     { 
     this.sURL = sURL; 
     this.nStartPos = nStart; 
     this.nEndPos = nEnd; 
     nThreadID = id; 
     fileAccessI = new FileAccessI(sName,nStartPos); 
     } 
     public void run() 
     { 
     while(nStartPos < nEndPos && !bStop) 
     { 
     try{ 
     URL url = new URL(sURL); 
     HttpURLConnection httpConnection = (HttpURLConnection)url.openConnection (); 
     httpConnection.setRequestProperty("User-Agent","NetFox"); 
     String sProperty = "bytes="+nStartPos+"-"; 
     httpConnection.setRequestProperty("RANGE",sProperty); 
     Utility.log(sProperty); 
     InputStream input = httpConnection.getInputStream(); 
     //logResponseHead(httpConnection); 
     byte[] b = new byte[1024]; 
     int nRead; 
     while((nRead=input.read(b,0,1024)) > 0 && nStartPos < nEndPos 
     && !bStop) 
     { 
     nStartPos += fileAccessI.write(b,0,nRead); 
     //if(nThreadID == 1) 
     // Utility.log("nStartPos = " + nStartPos + ", nEndPos = " + nEndPos); 
     } 
     Utility.log("Thread " + nThreadID + " is over!"); 
     bDownOver = true; 
     //nPos = fileAccessI.write (b,0,nRead); 
     } 
     catch(Exception e){e.printStackTrace ();} 
     } 
     } 
     // 打印回應(yīng)的頭信息
     public void logResponseHead(HttpURLConnection con) 
     { 
     for(int i=1;;i++) 
     { 
     String header=con.getHeaderFieldKey(i); 
     if(header!=null) 
     //responseHeaders.put(header,httpConnection.getHeaderField(header)); 
     Utility.log(header+" : "+con.getHeaderField(header)); 
     else 
     break; 
     } 
     } 
     public void splitterStop() 
     { 
     bStop = true; 
     } 
     } 
     
     /* 
     **FileAccess.java 
     */ 
     package NetFox; 
     import java.io.*; 
     public class FileAccessI implements Serializable{ 
     RandomAccessFile oSavedFile; 
     long nPos; 
     public FileAccessI() throws IOException 
     { 
     this("",0); 
     } 
     public FileAccessI(String sName,long nPos) throws IOException 
     { 
     oSavedFile = new RandomAccessFile(sName,"rw"); 
     this.nPos = nPos; 
     oSavedFile.seek(nPos); 
     } 
     public synchronized int write(byte[] b,int nStart,int nLen) 
     { 
     int n = -1; 
     try{ 
     oSavedFile.write(b,nStart,nLen); 
     n = nLen; 
     } 
     catch(IOException e) 
     { 
     e.printStackTrace (); 
     } 
     return n; 
     } 
     } 
     
     /* 
     **SiteInfoBean.java 
     */ 
     package NetFox; 
     public class SiteInfoBean { 
     private String sSiteURL; //Site's URL 
     private String sFilePath; //Saved File's Path 
     private String sFileName; //Saved File's Name 
     private int nSplitter; //Count of Splited Downloading File 
     public SiteInfoBean() 
     { 
     //default value of nSplitter is 5 
     this("","","",5); 
     } 
     public SiteInfoBean(String sURL,String sPath,String sName,int nSpiltter)
     { 
     sSiteURL= sURL; 
     sFilePath = sPath; 
     sFileName = sName; 
     this.nSplitter = nSpiltter; 
     } 
     public String getSSiteURL() 
     { 
     return sSiteURL; 
     } 
     public void setSSiteURL(String value) 
     { 
     sSiteURL = value; 
     } 
     public String getSFilePath() 
     { 
     return sFilePath; 
     } 
     public void setSFilePath(String value) 
     { 
     sFilePath = value; 
     } 
     public String getSFileName() 
     { 
     return sFileName; 
     } 
     public void setSFileName(String value) 
     { 
     sFileName = value; 
     } 
     public int getNSplitter() 
     { 
     return nSplitter; 
     } 
     public void setNSplitter(int nCount) 
     { 
     nSplitter = nCount; 
     } 
     } 
     
     /* 
     **Utility.java 
     */ 
     package NetFox; 
     public class Utility { 
     public Utility() 
     { 
     } 
     public static void sleep(int nSecond) 
     { 
     try{ 
     Thread.sleep(nSecond); 
     } 
     catch(Exception e) 
     { 
     e.printStackTrace (); 
     } 
     } 
     public static void log(String sMsg) 
     { 
     System.err.println(sMsg); 
     } 
     public static void log(int sMsg) 
     { 
     System.err.println(sMsg); 
     } 
     } 
     
     /* 
     **TestMethod.java 
     */ 
     package NetFox; 
     public class TestMethod { 
     public TestMethod() 
     { ///xx/weblogic60b2_win.exe 
     try{ 
     SiteInfoBean bean = new SiteInfoBean("http://localhost/xx/weblogic60b2_win.exe",
         "L:\\temp","weblogic60b2_win.exe",5); 
     //SiteInfoBean bean = new SiteInfoBean("http://localhost:8080/down.zip","L:\\temp",
         "weblogic60b2_win.exe",5); 
     SiteFileFetch fileFetch = new SiteFileFetch(bean); 
     fileFetch.start(); 
     } 
     catch(Exception e){e.printStackTrace ();} 
     } 
     public static void main(String[] args) 
     { 
     new TestMethod(); 
     } 
     }
    


    posted @ 2012-05-23 15:13 askzs 閱讀(681) | 評(píng)論 (0)編輯 收藏


    如圖:



    下載地址:http://m.tkk7.com/Files/f6k66ve/qzoneedit-64.rar

    有好多朋友說(shuō)在chrome瀏覽器下不能使用,看了下代碼,js中用到parent,在ie下js支持的很好,但是chrome對(duì)parnet支持的并不是很好,就是在本地測(cè)試時(shí),不能顯示,也不能使用,但是要把程序放到服務(wù)器上,就能很好的支持,能很好的使用,還有一點(diǎn)要注意,如果放到本機(jī)的服務(wù)器上,不要用localhost訪問(wèn),要用127.0.0.1訪問(wèn),我把程序放到tomcat下,直接訪問(wèn)http://localhost:8080/qw/ 則不能正確使用,但是http://127.0.0.1:8080/qw/ 這個(gè)地址能很好的訪問(wèn),我就不截圖了,總之一句話,這個(gè)編輯器是能在chrome下使用的,程序需要web服務(wù)器的支持

    posted @ 2010-07-20 16:49 askzs 閱讀(2638) | 評(píng)論 (7)編輯 收藏

    北冥有魚(yú),其名為鯤。鯤之大,不知其幾千里也;化而為鳥(niǎo),其名為鵬。鵬之背,不知其幾千里也;怒而飛,其翼若垂天之云 。是鳥(niǎo)也,海運(yùn)則將徙于南冥。南冥者,天池也。《齊諧》者,志怪者也 ?!吨C》之言曰:“鵬之徙于南冥也,水擊三千里,摶扶搖而上者九萬(wàn)里,去以六月息者也。”野馬也,塵埃也,生物之以息相吹也。天之蒼蒼,其正色邪?其遠(yuǎn)而無(wú)所至極邪?其視下也,亦若是則已矣。且夫水之積也不厚,則其負(fù)大舟也無(wú)力。覆杯水于坳堂之上,則芥為之舟,置杯焉則膠,水淺而舟大也。風(fēng)之積也不厚,則其負(fù)大翼也無(wú)力。故九萬(wàn)里,則風(fēng)斯在下矣,而后乃今培風(fēng);背負(fù)青天,而莫之夭閼者,而后乃今將圖南。蜩與學(xué)鳩笑之曰:“我決起而飛 ,搶榆枋而止,時(shí)則不至,而控于地而已矣,奚以之九萬(wàn)里而南為?”適莽蒼者,三餐而反,腹猶果然;適百里者,宿舂糧;適千里者,三月聚糧。之二蟲(chóng)又何知!小知不及大知,小年不及大年。奚以知其然也?朝菌不知晦朔,蟪蛄不知春秋,此小年也。楚之南有冥靈者,以五百歲為春,五百歲為秋;上古有大椿者,以八千歲為春,八千歲為秋,此大年也。而彭祖乃今以久特聞,眾人匹之,不亦悲乎?  湯之問(wèn)棘也是已:“窮發(fā)之北,有冥海者,天池也。有魚(yú)焉,其廣數(shù)千里,未有知其修者,其名為鯤。有鳥(niǎo)焉,其名為鵬,背若泰山,翼若垂天之云,摶扶搖羊角而上者九萬(wàn)里,絕云氣,負(fù)青天,然后圖南,且適南冥也。斥鴳笑之曰:‘彼且奚適也?我騰躍而上,不過(guò)數(shù)仞而下,翱翔蓬蒿之間,此亦飛之至也。而彼且奚適也?’”此小大之辯也。故夫知效一官、行比一鄉(xiāng) 、德合一君、而征一國(guó)者,其自視也,亦若此矣。而宋榮子猶然笑之。且舉世譽(yù)之而不加勸,舉世非之而不加沮,定乎內(nèi)外之分,辯乎榮辱之境,斯已矣。彼其于世,未數(shù)數(shù)然也。雖然,猶有未樹(shù)也。夫列子御風(fēng)而行,泠然善也,旬有五日而后反。彼于致福者,未數(shù)數(shù)然也。此雖免乎行,猶有所待者也。若夫乘天地之正,而御六氣之辯,以游無(wú)窮者,彼且惡乎待哉?故曰:至人無(wú)己,神人無(wú)功,圣人無(wú)名.
    posted @ 2010-06-08 09:15 askzs 閱讀(179) | 評(píng)論 (0)編輯 收藏

    Ajax+Flash多文件上傳是一個(gè)開(kāi)源的上傳組件,名稱是FancyUpload,其官方網(wǎng)址是:http://digitarald.de/project/fancyupload/。這個(gè)組件僅僅是客戶端的應(yīng)用組件,即與任何服務(wù)器端的技術(shù)沒(méi)有關(guān)系,服務(wù)器端可以采用任何后臺(tái)技術(shù)(如JSP、Servlet、ASP等)。應(yīng)用該組件提供 給我們的最大的好處有如下幾點(diǎn)(個(gè)人認(rèn)為,呵呵):

    1          僅是客戶端的應(yīng)用組件,服務(wù)器端可以采用任何后臺(tái)技術(shù)  ;
    2 可以同時(shí)選擇多個(gè)文件進(jìn)行上傳;
    3         以隊(duì)列的形式排列要上傳的文件和其相關(guān)信息(如名稱、大小等);
    4        
    可以設(shè)置要上傳的文件個(gè)數(shù)、文件類(lèi)型和文件大?。?span style="font-family: Wingdings;">
    5         有上傳進(jìn)度顯示, 直觀,實(shí)用);
    6      
    上傳的過(guò)程中可以隨時(shí)取消要上傳的文件;
    7      
    平臺(tái)獨(dú)立性,由于使用flash和 成熟的AJAX框架(mootools)可以避免對(duì)特定瀏覽器和服務(wù)器依賴!
    8       
    使用簡(jiǎn)單,文件體積??!
    9
      表單無(wú)須設(shè)置enctype="multipart/form-data"


    posted @ 2010-06-07 15:46 askzs 閱讀(1172) | 評(píng)論 (1)編輯 收藏

    轉(zhuǎn)載于http://blog.csdn.net/sunyujia/archive/2008/06/15/2549347.aspx

    <html>   
    <head>   
     
    <title>Add Files</title>   
     
    <style>   
     
    a.addfile {   
     
    background-image:url(http://p.mail.163.com/js31style/lib/0703131650/163blue/f1.gif);   
     
    background-repeat:no-repeat;   
     
    background-position:-823px -17px;   
     
    display:block;   
     
    float:left;   
     
    height:20px;   
     
    margin-top:-1px;   
     
    position:relative;   
     
    text-decoration:none;   
     
    top:0pt;   
     
    width:80px;   
     
    }   
     
     
     
    input.addfile {   
     
    /*left:-18px;*/  
     
    }   
     
     
     
    input.addfile {   
     
    cursor:pointer !important;   
     
    height:18px;   
     
    left:-13px;   
     
    filter:alpha(opacity=0);    
     
    position:absolute;   
     
    top:5px;   
     
    width:1px;   
     
    z-index: -1;   
     
    }   
     
    </style>   
     
     
     
    <script type="text/javascript">   
     
     
     
    function MultiSelector(list_target, max)   
     
    {   
     
        // Where to write the list   
     
        this.list_target = list_target;   
     
        // How many elements?   
     
        this.count = 0;   
     
        // How many elements?   
     
        this.id = 0;   
     
        // Is there a maximum?   
     
        if (max)   
     
        {   
     
            this.max = max;   
     
        }    
     
        else    
     
        {   
     
            this.max = -1;   
     
        };   
     
     
     
        /**  
     
         * Add a new file input element  
     
         */  
     
        this.addElement = function(element)   
     
        {   
     
            // Make sure it's a file input element   
     
            if (element.tagName == 'INPUT' && element.type == 'file')   
     
            {   
     
                // Element name -- what number am I?   
     
                element.name = 'file_' + this.id++;   
     
     
     
                // Add reference to this object   
     
                element.multi_selector = this;   
     
     
     
                // What to do when a file is selected   
     
                element.onchange = function()   
     
                {   
     
                    // New file input   
     
                    var new_element = document.createElement('input');   
     
                    new_element.type = 'file';   
     
                    new_element.size = 1;   
     
                    new_element.className = "addfile";   
     
     
     
                    // Add new element   
     
                    this.parentNode.insertBefore(new_element, this);   
     
     
     
                    // Apply 'update' to element   
     
                    this.multi_selector.addElement(new_element);   
     
     
     
                    // Update list   
     
                    this.multi_selector.addListRow(this);   
     
     
     
                    // Hide this: we can't use display:none because Safari doesn't like it   
     
                    this.style.position = 'absolute';   
     
                    this.style.left = '-1000px';   
     
                };   
     
     
     
     
     
                // If we've reached maximum number, disable input element   
     
                if (this.max != -1 && this.count >= this.max)   
     
                {   
     
                    element.disabled = true;   
     
                };   
     
     
     
                // File element counter   
     
                this.count++;   
     
                // Most recent element   
     
                this.current_element = element;   
     
            }    
     
            else    
     
            {   
     
                // This can only be applied to file input elements!   
     
                alert('Error: not a file input element');   
     
            };   
     
        };   
     
     
     
     
     
        /**  
     
         * Add a new row to the list of files  
     
         */  
     
        this.addListRow = function(element)   
     
        {   
     
            // Row div   
     
            var new_row = document.createElement('div');   
     
     
     
            // Delete button   
     
            var new_row_button = document.createElement('input');   
     
            new_row_button.type = 'button';   
     
            new_row_button.value = 'Delete';   
     
     
     
            // References   
     
            new_row.element = element;   
     
     
     
            // Delete function   
     
            new_row_button.onclick = function()   
     
            {   
     
                // Remove element from form   
     
                this.parentNode.element.parentNode.removeChild(this.parentNode.element);   
     
     
     
                // Remove this row from the list   
     
                this.parentNode.parentNode.removeChild(this.parentNode);   
     
     
     
                // Decrement counter   
     
                this.parentNode.element.multi_selector.count--;   
     
     
     
                // Re-enable input element (if it's disabled)   
     
                this.parentNode.element.multi_selector.current_element.disabled = false;   
     
     
     
                // Appease Safari   
     
                // without it Safari wants to reload the browser window   
     
                // which nixes your already queued uploads   
     
                return false;   
     
            };   
     
     
     
            // Set row value   
     
            new_row.innerHTML = element.value + " ";   
     
     
     
            // Add button   
     
            new_row.appendChild(new_row_button);   
     
     
     
            // Add it to the list   
     
            this.list_target.appendChild(new_row);   
     
        };   
     
    };   
     
    </script>   
     
    </head>   
     
     
     
    <body>   
     
     
     
    <!-- This is the form -->   
     
    <form enctype="multipart/form-data" action="http://127.0.0.1:8080/zzgh/cx/upload.jsp" method="post">   
     
    <!-- The file element -- NOTE: it has an ID -->   
     
    <a href="javascript:void(1==1);" class="addfile" style="cursor: default;" hidefocus="true">   
     
    <input id="my_file_element" class="addfile" type="file" name="file_1" size="1" title="點(diǎn)擊選擇附件">   
     
    </a>   
     
    <input type="submit" value="上 傳">   
     
    </form>   
     
     
     
    Files:   
     
    <!-- This is where the output will appear -->   
     
    <div id="files_list" style="padding:5px;border:1px;border-style:solid;border-color:#0000ff;height:100px;width:600px;"></div>   
     
    <script>   
     
    <!-- Create an instance of the multiSelector class, pass it the output target and the max number of files -->   
     
    var multi_selector = new MultiSelector(document.getElementById('files_list'), 100);   
     
    <!-- Pass in the file element -->   
     
    multi_selector.addElement(document.getElementById('my_file_element'));   
     
    </script>   
    </body>   
     
    </html> 


    效果圖如下:



    posted @ 2010-06-04 17:12 askzs 閱讀(436) | 評(píng)論 (0)編輯 收藏

    一,先新建一個(gè)excel文件,調(diào)整格式(就是你所想要顯示的格式),
    二,把剛才新建的excel文件令存為.html(demo.html)文件,
    三,新建一個(gè)jsp頁(yè)面, 在該JSP頁(yè)面頭部設(shè)置response的ContentType為Excel格式
    <% response.setContentType("application/vnd.ms-excel;charset=GBK"); %>
    然后設(shè)置網(wǎng)頁(yè)資料是以excel報(bào)表以線上瀏覽方式呈現(xiàn)或者是下載的方式呈現(xiàn)
    <%
    / /這行設(shè)定傳送到前端瀏覽器時(shí)的檔名為test1.xls  就是靠這一行,讓前端瀏覽器以為接收到一個(gè)excel檔 
     //將網(wǎng)頁(yè)資料以excel報(bào)表以線上瀏覽方式呈現(xiàn)
    response.setHeader("Content-disposition","inline; filename=test1.xls");
       //將網(wǎng)頁(yè)資料以下載的方式
    response.setHeader("Content-disposition","attachment; filename=test2.xls");
    %>
    然后把 demo.html的源代碼粘貼在jsp頁(yè)面,如下

    <%@ page contentType="text/html; charset=GBK" %>
    <% response.setContentType("application/vnd.ms-excel;charset=GBK");
    response.setHeader("Content-disposition","attachment; filename=test2.xls");

    %>
    <!--以下為保持成html頁(yè)面的excel的內(nèi)容 demo.html頁(yè)面-->
    <html xmlns:o="urn:schemas-microsoft-com:office:office"
    xmlns:x="urn:schemas-microsoft-com:office:excel"
    xmlns="http://www.w3.org/TR/REC-html40">

    <head>
    <meta http-equiv=Content-Type content="text/html; charset=gb2312">
    <meta name=ProgId content=Excel.Sheet>
    <meta name=Generator content="Microsoft Excel 11">
    <link rel=File-List href="qwe.files/filelist.xml">
    <link rel=Edit-Time-Data href="qwe.files/editdata.mso">
    <link rel=OLE-Object-Data href="qwe.files/oledata.mso">
    <!--[if gte mso 9]><xml>
     <o:DocumentProperties>
      <o:Created>1996-12-17T01:32:42Z</o:Created>
      <o:LastSaved>2010-05-12T13:59:04Z</o:LastSaved>
      <o:Version>11.9999</o:Version>
     </o:DocumentProperties>
     <o:OfficeDocumentSettings>
      <o:RemovePersonalInformation/>
     </o:OfficeDocumentSettings>
    </xml><![endif]-->
    <style>
    <!--table
     {mso-displayed-decimal-separator:"\.";
     mso-displayed-thousand-separator:"\,";}
    @page
     {margin:1.0in .75in 1.0in .75in;
     mso-header-margin:.5in;
     mso-footer-margin:.5in;}
    tr
     {mso-height-source:auto;
     mso-ruby-visibility:none;}
    col
     {mso-width-source:auto;
     mso-ruby-visibility:none;}
    br
     {mso-data-placement:same-cell;}
    .style0
     {mso-number-format:General;
     text-align:general;
     vertical-align:bottom;
     white-space:nowrap;
     mso-rotate:0;
     mso-background-source:auto;
     mso-pattern:auto;
     color:windowtext;
     font-size:12.0pt;
     font-weight:400;
     font-style:normal;
     text-decoration:none;
     font-family:宋體;
     mso-generic-font-family:auto;
     mso-font-charset:134;
     border:none;
     mso-protection:locked visible;
     mso-style-name:常規(guī);
     mso-style-id:0;}
    td
     {mso-style-parent:style0;
     padding-top:1px;
     padding-right:1px;
     padding-left:1px;
     mso-ignore:padding;
     color:windowtext;
     font-size:12.0pt;
     font-weight:400;
     font-style:normal;
     text-decoration:none;
     font-family:宋體;
     mso-generic-font-family:auto;
     mso-font-charset:134;
     mso-number-format:General;
     text-align:general;
     vertical-align:bottom;
     border:none;
     mso-background-source:auto;
     mso-pattern:auto;
     mso-protection:locked visible;
     white-space:nowrap;
     mso-rotate:0;}
    ruby
     {ruby-align:left;}
    rt
     {color:windowtext;
     font-size:9.0pt;
     font-weight:400;
     font-style:normal;
     text-decoration:none;
     font-family:宋體;
     mso-generic-font-family:auto;
     mso-font-charset:134;
     mso-char-type:none;
     display:none;}
    -->
    </style>
    <!--[if gte mso 9]><xml>
     <x:ExcelWorkbook>
      <x:ExcelWorksheets>
       <x:ExcelWorksheet>
        <x:Name>Sheet1</x:Name>
        <x:WorksheetOptions>
         <x:DefaultRowHeight>285</x:DefaultRowHeight>
         <x:CodeName>Sheet1</x:CodeName>
         <x:Selected/>
         <x:Panes>
          <x:Pane>
           <x:Number>3</x:Number>
           <x:ActiveCol>1</x:ActiveCol>
          </x:Pane>
         </x:Panes>
         <x:ProtectContents>False</x:ProtectContents>
         <x:ProtectObjects>False</x:ProtectObjects>
         <x:ProtectScenarios>False</x:ProtectScenarios>
        </x:WorksheetOptions>
       </x:ExcelWorksheet>
       <x:ExcelWorksheet>
        <x:Name>Sheet2</x:Name>
        <x:WorksheetOptions>
         <x:DefaultRowHeight>285</x:DefaultRowHeight>
         <x:CodeName>Sheet2</x:CodeName>
         <x:ProtectContents>False</x:ProtectContents>
         <x:ProtectObjects>False</x:ProtectObjects>
         <x:ProtectScenarios>False</x:ProtectScenarios>
        </x:WorksheetOptions>
       </x:ExcelWorksheet>
       <x:ExcelWorksheet>
        <x:Name>Sheet3</x:Name>
        <x:WorksheetOptions>
         <x:DefaultRowHeight>285</x:DefaultRowHeight>
         <x:CodeName>Sheet3</x:CodeName>
         <x:ProtectContents>False</x:ProtectContents>
         <x:ProtectObjects>False</x:ProtectObjects>
         <x:ProtectScenarios>False</x:ProtectScenarios>
        </x:WorksheetOptions>
       </x:ExcelWorksheet>
      </x:ExcelWorksheets>
      <x:WindowHeight>4530</x:WindowHeight>
      <x:WindowWidth>8505</x:WindowWidth>
      <x:WindowTopX>480</x:WindowTopX>
      <x:WindowTopY>120</x:WindowTopY>
      <x:AcceptLabelsInFormulas/>
      <x:ProtectStructure>False</x:ProtectStructure>
      <x:ProtectWindows>False</x:ProtectWindows>
     </x:ExcelWorkbook>
    </xml><![endif]-->
    </head>

    <body link=blue vlink=purple>

    <table x:str border=0 cellpadding=0 cellspacing=0 width=288 style='border-collapse:
     collapse;table-layout:fixed;width:216pt'>
     <col width=72 span=4 style='width:54pt'>
     <tr height=19 style='height:14.25pt'>
      <td height=19 width=72 style='height:14.25pt;width:54pt'>全球</td>
      <td width=72 style='width:54pt'>問(wèn)問(wèn)</td>
      <td width=72 style='width:54pt'>ee</td>
      <td width=72 style='width:54pt'>rr</td>
     </tr>
     <tr height=19 style='height:14.25pt'>
      <td height=19 style='height:14.25pt'>暗暗</td>
      <td>ss</td>
      <td>dd</td>
      <td>ff</td>
     </tr>
     <![if supportMisalignedColumns]>
     <tr height=0 style='display:none'>
      <td width=72 style='width:54pt'></td>
      <td width=72 style='width:54pt'></td>
      <td width=72 style='width:54pt'></td>
      <td width=72 style='width:54pt'></td>
     </tr>
     <![endif]>
    </table>

    </body>

    </html>


    中文問(wèn)題:
    查看源代碼時(shí)發(fā)現(xiàn)JSP文件中寫(xiě)死的中文為亂碼,則在JSP文件頭部添加一行
    <%@ page contentType="text/html; charset=gb2312" %>
    查看源代碼時(shí)發(fā)現(xiàn)文字為中文,但是用Excel打開(kāi)為亂碼則在<html>與<head>中加入
    <meta http-equiv="Content-Type" content="text/html; charset=GBK">

    在jsp頁(yè)面中,要在excel中顯示的內(nèi)容可以從數(shù)據(jù)庫(kù)中讀取,在此就不做詳細(xì)的介紹了

    posted @ 2010-05-12 22:06 askzs 閱讀(4740) | 評(píng)論 (0)編輯 收藏

    我要啦免费统计
    主站蜘蛛池模板: 免费大片在线观看网站| 日本不卡免费新一二三区| 精品国产亚洲一区二区三区| 美女免费精品高清毛片在线视| 麻豆国产VA免费精品高清在线| 一本色道久久88亚洲精品综合| 久久久久国产精品免费免费搜索| 亚洲一区二区三区在线网站| 免费看韩国黄a片在线观看| 中文字幕精品三区无码亚洲| 天天拍拍天天爽免费视频| 亚洲人成网亚洲欧洲无码| 日本一区免费电影| 九九免费精品视频在这里| 2022中文字字幕久亚洲| 香蕉视频在线免费看| 国产亚洲精品a在线观看app | 日韩免费高清视频| 在线看亚洲十八禁网站| 久久久青草青青国产亚洲免观| 巨胸喷奶水www永久免费| 亚洲国产另类久久久精品黑人| 日本在线免费观看| 亚洲av无码一区二区三区天堂古代| 成人无遮挡裸免费视频在线观看| 亚洲aⅴ无码专区在线观看春色 | 一级毛片免费全部播放| 亚洲情综合五月天| 国产在线观看麻豆91精品免费 | 国产午夜亚洲精品| 亚洲黄片毛片在线观看| 日本免费污片中国特一级| 亚洲国产视频久久| 在线亚洲精品自拍| 国产大片线上免费观看| 好猛好深好爽好硬免费视频| 亚洲视频日韩视频| 无码欧精品亚洲日韩一区夜夜嗨 | 久久亚洲精品专区蓝色区| 全部免费毛片在线| 91av免费观看|