我正在尝试保存一个简单的模板到pdf使用渲染插件,但我不能让它工作,无论我尝试什么。我所需要的就是让它在服务器上的文件系统中保存一个文件,并重定向到另一个页面。
此时,pdf模板不需要任何参数,因为它只输出hello world。一旦我得到了这个工作,我将尝试添加一些数据。
如果没有附加'/‘,我就会收到错误,说我需要指定一个控制器。但我已尝试添加此功能,但无济于事。另外,我不知道它需要哪个控制器,因为我已经尝试指定了这个操作被声明的控制器。
有没有人能看看这个,告诉我我哪里做错了?
RenderingService pdfRenderingService
def displayPDFSummary = {
ByteArrayOutputStream bytes = pdfRenderingService.render(template: "_pdfTemplate", controller:"RSSCustomerOrder", model: [origSessionId:params.origSessionId])
def fos= new FileOutputStream('NewTestFile.pdf')
fos.write(bytes)
fos.close()
render(template: "_pdfTemplate", params: [origSessionId:params.origSessionId])
}我在控制台中收到以下错误消息:
groovy.lang.MissingMethodException: No signature of method: java.io.FileOutputStream.write() is applicable for argument types: (java.io.ByteArrayOutputStream)
(Then prints contents of template...)
Possible solutions: write([B), write(int), write([B), write(int), wait(), wait(long)发布于 2012-06-18 23:47:20
你看过FileOutputStream docs了吗?没有写(OutputStream)方法。
试试fos.write(bytes.toByteArray())。此外,bytes.writeTo(fos)可能会起作用。
https://stackoverflow.com/questions/11085627
复制相似问题