- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
采用dwr+ajax和struts开发文件上传进度条.doc
采用dwr+ajax和struts开发文件上传进度条
不用自己写了,源码可以从
http://www.telio.be/blog/2006/01/06/ajax-upload-progress-monitor-for-commons-fileupload-example里面下载,
下载地址
http://www.telio.be/blog/wp-content/uploads/2006/01/ajax-upload-1.0.war
下载完之后,你需要解包,在命令行中:
jar xvf ajax-upload-1.0.war
源码就在\WEB-INF\src下面
将要用到的文件有resources文件夹下,\WEB-INF\下面的dwr.xml和lib下面的jar文件
上传页面
在上面解开的包里面有index.jsp这个是上传页面,upload.jsp负责上传,resources包里面包含了dwr与服务器通讯的javascript脚本,你需要把index.jsp的form中的action换成你的struts action即可,然后把form中的file名改成你actionform中的file属性名,把页面中剩余的file去掉
index.jsp上传页面示例代码:
%@ page contentType=text/html; charset=gb2312 language=java import=java.util.* errorPage=%
%
String path=request.getContextPath();
%
html locale=true
head
SCRIPT language=javascript
function check_file() {
var strFileName=document.forms(0).file;
if (strFileName.value==){
alert(请选择要上传的文件);
return false;
}
startProgress();
}
function loadmessage(){
%
if (request.getAttribute(message) != null) {
%
window.alert(%=request.getAttribute(message)%);
window.returnValue=yes;
%}%
}
/SCRIPT
title上传/title
script src=%=path%/resources/js/upload.js /script
script src=%=path%/dwr/interface/UploadMonitor.js /script
script src=%=path%/dwr/engine.js /script
script src=%=path%/dwr/util.js /script
style type=text/css
#progressBar { padding-top: 5px; }
#progressBarBox { width: 350px; height: 20px; border: 1px inset; background: #eee;}
#progressBarBoxContent { width: 0; height: 20px; border-right: 1px solid #444; background: blue; }
/style
LINK href=%=path%/css/style.css type=text/css rel=stylesheet
meta http-equiv=Content-Type content=text/html; charset=gb2312
/head
style type=text/css
!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
--
/style
body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0 onLoad=loadmessage()
form name=form method=post acti
文档评论(0)