Forcing the browser to download a docx file in JAVA generates a corrupted document

后端 未结 1 603
栀梦
栀梦 2021-01-24 21:08

Using JAVA, I\'m trying to force the browser to download files.

Here is the code I currently use:

response.reset         


        
相关标签:
1条回答
  • 2021-01-24 21:31

    I tried by chance to add more headers, and in fact, the Content-Length header resolved the problem...

    So finally, I just add this line to make it work:

    response.setContentLength((int) file.length());
    
    0 讨论(0)
提交回复
热议问题