gpt4 book ai didi

已经为此响应调用了 Grails getOutputStream()

转载 作者:行者123 更新时间:2023-12-02 13:57:11 25 4
gpt4 key购买 nike

我的 Controller 中有这个方法。 Whick 基本上呈现 pdf 文件。

    def getUserInvoiceImage (GetInvoiceDataCommand form) {
byte[] pdf = invoiceImageService.getUserInvoiceImage(form.invoiceId)
response.setContentType('application/pdf')
response.outputStream << pdf;
response.outputStream.close()
return false;
}

当我双击它时,它工作正常。但是当我折叠并展开我的面板时,会发生以下异常。
    Software caused connection abort: socket write error. Stacktrace follows:
java.net.SocketException: Software caused connection abort: socket write error
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at net.bull.javamelody.FilterServletOutputStream.write(FilterServletOutputStream.java:64)
at net.bull.javamelody.CounterResponseStream.write(CounterResponseStream.java:75)
at com.tieto.msi.InvoiceImageController.getUserInvoiceImage(InvoiceImageController.groovy:13)
at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:195)
at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
at net.bull.javamelody.JspWrapper.invoke(JspWrapper.java:151)
at net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(JdbcWrapper.java:271)
at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:206)
at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:179)
at jcifs.http.NtlmHttpFilter.doFilter(NtlmHttpFilter.java:154)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:662)
2013-08-19 12:43:15,636 ERROR KULDARIM org.codehaus.groovy.grails.web.errors.GrailsExceptionResolver: IllegalStateException occurred when processing request: [GET] /MySupplierInvoices/invoiceImage/getUserInvoiceImage - parameters:
invoiceId: 5274216
getOutputStream() has already been called for this response. Stacktrace follows:
org.codehaus.groovy.grails.web.pages.exceptions.GroovyPagesException: Error processing GroovyPageView: getOutputStream() has already been called for this response
at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:195)
at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
at net.bull.javamelody.JspWrapper.invoke(JspWrapper.java:151)
at net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(JdbcWrapper.java:271)
at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:206)
at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:179)
at jcifs.http.NtlmHttpFilter.doFilter(NtlmHttpFilter.java:154)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.IllegalStateException: getOutputStream() has already been called for this response
at net.bull.javamelody.FilterServletResponseWrapper.getWriter(FilterServletResponseWrapper.java:121)
at C__Dev_MyApps_MySupplierInvoices_grails_app_views_error500_gsp.run(error500.gsp:1)
... 10 more
2013-08-19 12:43:15,639 WARN grails.plugin.cache.web.filter.simple.MemoryPageFragmentCachingFilter: Throwable thrown during doFilter on request with URI: /MySupplierInvoices/grails/invoiceImage/getUserInvoiceImage.dispatch and Query: invoiceId=5274216 : Request processing failed; nested exception is org.codehaus.groovy.grails.web.pages.exceptions.GroovyPagesException: Error processing GroovyPageView: getOutputStream() has already been called for this response
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.codehaus.groovy.grails.web.pages.exceptions.GroovyPagesException: Error processing GroovyPageView: getOutputStream() has already been called for this response
at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:195)
at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
at net.bull.javamelody.JspWrapper.invoke(JspWrapper.java:151)
at net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(JdbcWrapper.java:271)
at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:206)
at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:179)
at jcifs.http.NtlmHttpFilter.doFilter(NtlmHttpFilter.java:154)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.codehaus.groovy.grails.web.pages.exceptions.GroovyPagesException: Error processing GroovyPageView: getOutputStream() has already been called for this response
... 10 more
Caused by: java.lang.IllegalStateException: getOutputStream() has already been called for this response
at net.bull.javamelody.FilterServletResponseWrapper.getWriter(FilterServletResponseWrapper.java:121)
at C__Dev_MyApps_MySupplierInvoices_grails_app_views_error500_gsp.run(error500.gsp:1)
... 10 more
2013-08-19 12:43:15,640 ERROR org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/MySupplierInvoices].[grails]: Servlet.service() for servlet grails threw exception
java.lang.IllegalStateException: getOutputStream() has already been called for this response
at net.bull.javamelody.FilterServletResponseWrapper.getWriter(FilterServletResponseWrapper.java:121)
at C__Dev_MyApps_MySupplierInvoices_grails_app_views_error500_gsp.run(error500.gsp:1)
at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:195)
at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
at net.bull.javamelody.JspWrapper.invoke(JspWrapper.java:151)
at net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(JdbcWrapper.java:271)
at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:206)
at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:179)
at jcifs.http.NtlmHttpFilter.doFilter(NtlmHttpFilter.java:154)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:662)
2013-08-19 12:43:15,642 ERROR org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/MySupplierInvoices].[default]: Servlet.service() for servlet [default] in context with path [/MySupplierInvoices] threw exception [org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.codehaus.groovy.grails.web.pages.exceptions.GroovyPagesException: Error processing GroovyPageView: getOutputStream() has already been called for this response] with root cause
java.lang.IllegalStateException: getOutputStream() has already been called for this response
at net.bull.javamelody.FilterServletResponseWrapper.getWriter(FilterServletResponseWrapper.java:121)
at C__Dev_MyApps_MySupplierInvoices_grails_app_views_error500_gsp.run(error500.gsp:1)
at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:195)
at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
at net.bull.javamelody.JspWrapper.invoke(JspWrapper.java:151)
at net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(JdbcWrapper.java:271)
at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:206)
at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:179)
at jcifs.http.NtlmHttpFilter.doFilter(NtlmHttpFilter.java:154)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:662)

我已经阅读了很多关于这个问题的信息,但没有一个解决方案对我有帮助。所以,如果我做错了什么,或者只是我想要达到的这种行为是不可能的,我会有点困惑。

最佳答案

response.outputStream << pdf;

此代码将自动刷新您的响应,因此无需添加 close()之后。将您的代码更改为:
def getUserInvoiceImage (GetInvoiceDataCommand form) {
byte[] pdf = invoiceImageService.getUserInvoiceImage(form.invoiceId)
response.setContentType('application/pdf')
response.outputStream << pdf;
}

关于已经为此响应调用了 Grails getOutputStream(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18309515/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com