文件已被移动 - 无法再次读取 [英] File has been moved - cannot be read again

查看:134
本文介绍了文件已被移动 - 无法再次读取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将multipartfile存储到会话中,然后检索它以显示在表中。当我点击这个文件时,我得到如下错误,

这是我在控制器中的编码。如果我上传12KB大小的pdf文件,则没有错误。但是当我上传14KB大小的文件时,它显示错误像

 FIle已被移动 - 无法再读取。

请给我一些建议。谢谢。



 @RequestMapping(/ claim / transportation / download / {docId})
public String download(@PathVariable( docId)整数docId,@ ModelAttribute(dataHolderPrmClaimTransportationSession)DataHolderPrmClaimTransportationSession dataHolderPrmClaimTransportationSession,HttpServletResponse response){
System.out.print(docId);的System.out.println( 的DocID);
try {
response.setHeader(Content-Disposition,inline; filename = \+ dataHolderPrmClaimTransportationSession.getUiPrmClaimTransportation()。getTransportationRecordList()。get(docId).getUploadFile()。getOriginalFilename ()+ \);
System.out.println(DocIDHeader);
System.out.println(dataHolderPrmClaimTransportationSession.getUiPrmClaimTransportation()。getTransportationRecordList()。get(docId).getUploadFile()。getOriginalFilename());
OutputStream out = response.getOutputStream();
System.out.println(out);
response.setContentType(application / pdf);
IOUtils.copy(dataHolderPrmClaimTransportationSession.getUiPrmClaimTransportation()。getTransportationRecordList()。get(docId).getUploadFile()。getInputStream(),out);
out.flush();
out.close();
} catch(IOException e)
{
logger.error(e.getMessage(),e);
}

返回null;
}





< td id =selfTableAttachedFile>< a href = $ {pageContext.request.contextPath} / hra / prm / claim / transportation / download / $ {status.index}target =_ blank> $ {record.uploadFile.originalFilename}< / a>< / td> ; 

解决方案

{pageContext.request.contextPath} / hra / prm / claim / transportation / download /


{status.index}target =_ blank>


{record.uploadFile.originalFilename}< / a>< / td>


I stored multipartfile to session and I retrieved it to display in table. when I click on this file, I got the error as follow,
This is my coding in controller. If I upload 12KB size pdf file,it has no error. but when I upload 14KB size file, it shows error Like

FIle has been moved - cannot be read again.

Please give me some advice .Thanks.

@RequestMapping("/claim/transportation/download/{docId}")
    public String download(@PathVariable("docId") Integer docId, @ModelAttribute("dataHolderPrmClaimTransportationSession") DataHolderPrmClaimTransportationSession dataHolderPrmClaimTransportationSession,HttpServletResponse response){
        System.out.print(docId); System.out.println("DocID");
        try{
            response.setHeader("Content-Disposition", "inline;filename=\""+dataHolderPrmClaimTransportationSession.getUiPrmClaimTransportation().getTransportationRecordList().get(docId).getUploadFile().getOriginalFilename()+"\"");
            System.out.println("DocIDHeader");
            System.out.println(dataHolderPrmClaimTransportationSession.getUiPrmClaimTransportation().getTransportationRecordList().get(docId).getUploadFile().getOriginalFilename());
            OutputStream out=response.getOutputStream();
            System.out.println(out);
            response.setContentType("application/pdf");
            IOUtils.copy(dataHolderPrmClaimTransportationSession.getUiPrmClaimTransportation().getTransportationRecordList().get(docId).getUploadFile().getInputStream(),out);
            out.flush();
            out.close();
        }catch(IOException e)
        {
            logger.error(e.getMessage(),e);
        }

        return null;
    }



<td id="selfTableAttachedFile"><a href="${pageContext.request.contextPath}/hra/prm/claim/transportation/download/${status.index}" target="_blank">${record.uploadFile.originalFilename }</a></td>

解决方案

{pageContext.request.contextPath}/hra/prm/claim/transportation/download/


{status.index}" target="_blank">


{record.uploadFile.originalFilename }</a></td>


这篇关于文件已被移动 - 无法再次读取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆