Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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>
Posted
Updated 3-Feb-15 17:34pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900