首页 > 编程知识 正文

Springboot常用注解,springboot下载文件不全

时间:2023-05-04 16:29:06 阅读:127825 作者:1821

springboot文件下载小的demo一,准备指向前端页面的链接。 a href='./file/download? fileName=xxxx.xxx'xxx.xxx/a、控制器@请求映射()/download ) /返回值为void,无法响应跳转页面和响应流只能选择两个公共void的http servlet请求请求, 获取httpservletresponseresponse (throws exception (/下载的资源文件夹string realpath=request.get realpath ) ) //获取输出流的servletoutputstreamos=response.get output stream (; //response.setheader (content-disposition )、) attachment; filename=' urlencoder.encode (filename,' UTF-8 ' ); Ioutils.copy(is,os ); Ioutils.closequietly(is; Ioutils.closequietly(OS; }总结注意:只能选择一个响应跳转页和一个响应输入流。 否则,500就异常了。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。