I want to download a pdf file which is stored in the folder which is in WebContent of project

后端 未结 2 1193

This is my Strut file.


    

        
相关标签:
2条回答
  • 2021-01-22 22:11

    I have solved this question. I have stored the physical path of the file in the data base.For example if your project path is : D:/Workspace_ABC/SampleProject/WebContent/D-Files/APJ.AbdulKalam.pdf then store this path as it is in the database table. and then use this path to download file.

    0 讨论(0)
  • 2021-01-22 22:16

    The problem with

    String path2=request.getParameter("path1");
    

    This method may return null if parameter path1 is missing. If it's not null then it should be a valid path to the readable file that you application has access.

    Read the example How to read file in Java – FileInputStream. You can trace the output with the code.

    System.out.println("Total file size to read (in bytes) : "
                    + getFileInputStream().available()); 
    

    The getter is needed to return a stream result, and as you are using dynamic parameter in the result config. You should provide the getter for fileName.

    0 讨论(0)
提交回复
热议问题