1. Train of Thought
Paging data query, while caching the setup progress (percentage of total data for the current fetch point)
2, Interface progress bar for asynchronous request cache ratio
3, Code
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 filters, transparency 50%*/
-moz-opacity:0.5;/*firefox Private, transparency 50%*/
opacity:0.9;/* Other, transparency 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 >=) {
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 = Fetch current page data list<> List = (list<>) dbpage.getresult (); if (list!= null && list.size () > 0) {if (List.size () <) {Redistemplate.opsforvalue (). Set ("Down_process_ "+qm.getkey (), 100);} else{Double Process = i * 100.0/dbpage.gettotalcount () *; if (process < 0.1) process=0.1d; redistemplate.opsforval
UE (). Set ("Down_process_" +qm.getkey (), process);
} logger.info ("-------Value:" + redistemplate.opsforvalue (). Get ("Down_process_" +qm.getkey ()); if (list = = NULL | | list.size () <) {Redistemplate.opsforvalue (). Set ("Down_process_" +qm.getkey ()); break;} log
Ger.info ("-------Value:" + redistemplate.opsforvalue (). Get ("Down_process_" +qm.getkey ());
Continue }}catch () {}finally{redistemplate.opsforvalue (). Set ("Down_process_" +qm.getkey (), MB); 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 ()); }catch (Exception e) {process = 0.1d; E.printstacktrace ();} finally {return process;}}
The above is a small set to introduce JSP data paging export download show progress bar style, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!