如何在spring mvc中阅读下载的pdf文件?

时间:2014-08-24 10:26:26

标签: java spring spring-mvc pdf

我是春天的新人。所以我的问题是如何阅读下载的pdf文件.my jsp页面有pdf下载链接。当我点击该链接但我打开它时,pdf正在正确下载。它显示空白文件。那么任何人都可以告诉我如何阅读pdf文件

@RequestMapping(value = "/downloadfile", method = RequestMethod.GET)
public void downloadnotepadfile(HttpServletRequest request,
        HttpServletResponse response) {
    String filename = "Application-Form-2014";
    try {
        String path = "f:\\";
        PrintWriter out = response.getWriter();  

        File f = new File(path + "//" + filename);

        response.setContentType("application/pdf");
        response.setContentLength(new Long(f.length()).intValue());
        response.setHeader("Content-Disposition",
                "attachment; filename=\""+filename+"\"");


        PdfReader reader = new PdfReader(filename);
       int a = reader.getNumberOfPages();
        }

请帮帮我。

0 个答案:

没有答案