smartupload 路径不存在_求助:jspSmartUpload处理下载时文件路径中的空格怎么处理?? 400 报错-问答-阿里云开发者社区-阿里云...

我在使用SmartUpload处理下载是使用这个方法也不行,随后换了一个方法,使用

String path = request.getParameter("path").trim();

URLEncoder.encode(path,"UTF-8");

response.setContentType("application/octet-stream; CHARSET=utf8");

response.setHeader("Content-Disposition","attachment; filename="+path);就可以了,不知为何,这是调用SmartUpload的代码

if (path == null) {

response.setContentType("text/html; charset=UTF-8");

response.getWriter().print("文件不存在,或者禁止下载!");

return;

}

InputStream inStream = new FileInputStream(path);

response.reset();

SmartUpload su = new SmartUpload();

su.initialize(this.getServletConfig(), request, response);

su.setContentDisposition(null);

su.downloadFile(path);

byte[] b = new byte[100];

int len = 0;

while ((len = inStream.read(b)) > 0) {

response.getOutputStream().write(b, 0, len);

}

inStream.close();是不是我使用方法不正确啊?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值