Spring - display PDF-file in browser instead of downloading

后端 未结 2 537
误落风尘
误落风尘 2021-02-02 18:04

i am trying to display a pdf in my browser with spring. my problem is that the browser downloads the file instead of displaying it. this is my code:

@RequestMapp         


        
相关标签:
2条回答
  • 2021-02-02 18:11

    You are almost done. Just remove

    headers.setContentDispositionFormData(filename, filename);
    

    from your code block. It should be used when posting multipart/form-data to the server.

    0 讨论(0)
  • 2021-02-02 18:23

    Content-Disposition to control either download or view in browser

    View in browser

    headers.add("Content-Disposition", "inline; filename=" + "example.pdf");
    

    Download

    headers.add("Content-Disposition", "attachment; filename=" + "example.pdf");
    
    0 讨论(0)
提交回复
热议问题