相关疑难解决方法(0)

在Spring Portlet MVC Architecture中提供PDF - Liferay 6.0.6

我正在寻找一种通过Liferay Portal将PDF(直接显示)文件发送到浏览器的方法.找到了许多解决方案 - 最受欢迎的解决方案是编写一个可以完成工作的Servlet.我已经阅读了JSR 286规范中关于Portlet资源服务的内容,有人可以为Spring 3.0 Portlet MVC详细说明吗?

<servlet>
    <display-name>DownloadServlet</display-name>
    <servlet-name>DownloadServlet</servlet-name>
    <servlet-class>com.liferay.portal.pdf.DownloadServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>DownloadServlet</servlet-name>
    <url-pattern>/DownloadServlet/*</url-pattern>
</servlet-mapping>
Run Code Online (Sandbox Code Playgroud)

Servlet包括:

private void downloadServlet(HttpServletRequest req,
            HttpServletResponse resp) throws ServletException, IOException {

        logger.debug(" downloadServlet ::  ");
        BufferedInputStream bis = null;
        BufferedOutputStream bos = null;
        ServletOutputStream op = null;
        try {
            //Something
            pdfContentVO=//getpdf VO here

            String filename = "PDFFILE_"+pdfNumber+".pdf";

            op = resp.getOutputStream();
            resp.setContentType("application/pdf");     
            resp.setHeader("Content-Disposition", "attachment; filename="
                    + filename);
            resp.setContentLength(pdfContentVO.getPdfData().length); 
            System.out.println("pdfcontent"+pdfContentVO.getPdfData());
            op.write(pdfContentVO.getPdfData());
            op.flush();
            op.close();


         } catch(final IOException e) {
            System.out.println ( "IOException." );
            throw e;
        } …
Run Code Online (Sandbox Code Playgroud)

portal spring-mvc liferay liferay-6 spring-portlet-mvc

3
推荐指数
1
解决办法
7526
查看次数