JSP資料分頁匯出下載顯示進度條樣式_JSP編程

來源:互聯網
上載者:User

1、思路

分頁資料查詢,同時緩衝設定進度(為當前取出資料點總資料比例)

2、介面進度條 為 非同步請求緩衝比例

3、代碼

css:

body{position:relative;}.mask{position:absolute;left:0px;top:0px;height:100%;width:100%;background-color: #eee;display:none;filter:alpha(opacity=50); /*IE濾鏡,透明度50%*/-moz-opacity:0.5; /*Firefox私人,透明度50%*/opacity:0.9;/*其他,透明度50%*/z-index:999;}.out{margin:auto;margin-top:20%;text-align:center;height:30px;width:500px;background-color: #fff;border:1px solid red;position:relative;}.in{position:absolute;left:-1px;top:0px;height:28px;width:0px;background-color: red;}.num{position:absolute;left:0px;top:0px;height:30px;line-height:30px;width:500px;text-align:center;position:relative;}

js:

$(function(){$(.donwload).click(function(){var ulr = ----;var key = new Date().getTime();url+="?key="+key;downloadFile(url);process(key);});});function downloadFile(url) {try{var elemIF = document.createElement("iframe")elemIF.style.display = "none";document.body.appendChild(elemIF);elemIF.src = url;}catch(e){}}function process(key){$.ajax({type: 'GET',url: ----------,async:true,success:function (data) {if(data){data = parseFloat(data).toFixed(2);$(".in").css("width",(data/100*500)+"px");$(".num").text(data+"%");if(data >= 100){setTimeout(function(){$(".mask").hide();}, 3000);}else{setTimeout(function(){process(key);}, 1000);}}},error:function () {}});}

downaction

try{redisTemplate.opsForValue().set("down_process_"+qm.getKey(),0.1);int i = 0;while(true){qm.getPage().setNowPage(i++);qm.getPage().setPageSize(100);Page dbpage = 取當前頁資料List<> list = (List<>) dbpage.getResult();if(list != null && list.size() > 0){if(list.size() < 100) {redisTemplate.opsForValue().set("down_process_"+qm.getKey(), 100);}else{double process = i * 100.0 / dbpage.getTotalCount() * 100;if(process < 0.1)process=0.1d;redisTemplate.opsForValue().set("down_process_"+qm.getKey(), process);}}logger.info("-------value:" + redisTemplate.opsForValue().get("down_process_"+qm.getKey()));if(list == null || list.size() < 100) {redisTemplate.opsForValue().set("down_process_"+qm.getKey(),100);break;}logger.info("-------value:" + redisTemplate.opsForValue().get("down_process_"+qm.getKey()));continue;}}catch(){}finally{redisTemplate.opsForValue().set("down_process_"+qm.getKey(),100);redisTemplate.expire("down_process_"+qm.getKey(),5, TimeUnit.MINUTES);}public double process(HttpServletRequest request, HttpServletResponse response,@PathVariable(value ="key") String key) throws IOException {Double process = 0.1d;try{int i = 0;while(true) {if(i>=2){process = 100d;break;}i++;if (redisTemplate.opsForValue().get("down_process_"+key) == null) {Thread.currentThread().sleep(1000l);continue;}else{process = Double.valueOf(redisTemplate.opsForValue().get("down_process_"+key).toString());break;}}}catch (Exception e){process = 0.1d;e.printStackTrace();}finally {return process;}}

以上所述是小編給大家介紹的JSP資料分頁匯出下載顯示進度條樣式,希望對大家有所協助,如果大家有任何疑問請給我留言,小編會及時回複大家的。在此也非常感謝大家對雲棲社區網站的支援!

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.