我想一個PDF文件從我的控制器傳遞給我的看法,渲染PDF查看Grails的
我使用像渲染的方法看起來:
render (file: new File (result), fileName:"test.pdf", contentType:"application/pdf")
,其中結果: 「文件:/// d:/TempPartage/test.pdf」 的問題是,我得到了當前異常:
Content type could not be determined for file: test.pdf. Stacktrace follows: org.codehaus.groovy.grails.web.servlet.mvc.exceptions.ControllerExecutionException: Content type could not be determined for file: test.pdf at fr.mma.usage.EditionintercalaireController$$EQMXBXRn.copierPDF(EditionintercalaireController.groovy:154) at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:195) at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63) at fr.mma.use.logging.filter.HttpLoggingFilter.doFilter(HttpLoggingFilter.java:69) at fr.mma.souse.authentication.AnnuaireCredentialCheckerFilter.doFilter(AnnuaireCredentialCheckerFilter.groovy:84) at fr.mma.souse.security.mock.MockAuthenticationFilter.doFilter(MockAuthenticationFilter.groovy:60) at org.togglz.servlet.TogglzFilter.doFilter(TogglzFilter.java:100) at fr.mma.use.navigation.NexturlValidationFilter.doFilter(NexturlValidationFilter.groovy:52) at fr.mma.use.requestid.RequestIdFilter.doFilter(RequestIdFilter.groovy:38) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:722)
我到底做錯了什麼? THX幫助
THX它正常工作,以使這個文件,但現在這個錯誤:java.lang.IllegalStateException:getOutputStream()已經被調用這個響應,有時如果我雙擊它不會出現 – barthelemy
無論如何,你的解決方案工作得很好thx幫助 – barthelemy