您的位置:首页 > 其它

SVN:database disk image is malformed

2014-04-04 16:08 302 查看
发现很多地方需要用到进度条,研究了一下进度条的使用。

前端代码

<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<%@ include file="/WEB-INF/jsp/includes.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>Insert title here</title>
<link rel="stylesheet" href="/css/base.css" type="text/css" media="all" />
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/themes/base/jquery-ui.css" type="text/css" media="all" />
<link rel="stylesheet" href="http://static.jquery.com/ui/css/demo-docs-theme/ui.theme.css" type="text/css" media="all" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.min.js" type="text/javascript"></script>
<script src="http://jquery-ui.googlecode.com/svn/tags/latest/external/jquery.bgiframe-2.1.2.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/i18n/jquery-ui-i18n.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
var progressbar = $("#progressbar");
progressbar.progressbar({
value: 0
});

progressbar.total = 200;

$("#send").click(function(){
progressbar.count = 0;
for(var i = 0; i < progressbar.total; i++) {
$.get("/fews/progress/task.jhtml",function(){
plus(progressbar);
});
}
});
});

function plus(progressbar) {
progressbar.count++;
progressbar.progressbar("value", (progressbar.count/progressbar.total) * 100);
}

</script>
</head>
<body>
<div>
<input type="button" id="send" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" height="20px"></input>
<div id="progressbar"></div>
</div>
</body>
</html>

 共有两百次任务请求,每次任务执行完成,进度+1。

后端代码:

@Controller
public class ResponseProgressBar {
@RequestMapping("/progress/task.jhtml")
public void responseTask(HttpServletResponse response) {
try {
Thread.sleep(new Random().nextInt(500));
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

 随机一个500毫秒之内的时间返回请求。

可以看到进度条一点一点往上涨。

有一个问题,假如一次请求两百个任务,怎么使用进度条呢?
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: