主题:beetl在firefox浏览器下的一个异常

hlmxy 2020年03月18日 31

最新版本,在firefox下,后台会爆出一个异常,但是不影响前端显示,其他edge浏览器正常,不爆出这个异常。

不知道是不是个例。

2020-03-18 19:51:06,968 ERROR (DirectJDKLog.java:175)- Servlet.service() for servlet [dispatcherServlet] in context with path [/ztsys] threw exception [Request processing failed; nested exception is java.lang.IllegalStateException: getOutputStream() has already been called for this response] with root cause
java.lang.IllegalStateException: getOutputStream() has already been called for this response
    at org.apache.catalina.connector.Response.getWriter(Response.java:581)
    at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:227)
    at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:114)
    at org.beetl.ext.web.WebRender.render(WebRender.java:128)
    at org.beetl.ext.spring.BeetlSpringView.renderMergedTemplateModel(BeetlSpringView.java:123)
    at org.springframework.web.servlet.view.AbstractTemplateView.renderMergedOutputModel(AbstractTemplateView.java:179)
    at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:317)
    at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1372)
    at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1118)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1057)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

查了一下,

org.beetl.ext.web.WebRender.render(WebRender.java:128)
writer = response.getWriter();
template.renderTo(writer);

最终定位在这里

闲大赋 2020年03月18日

这个错误原因是流已经关闭,但后续某个代码还在操作流程,Beetl在渲染模板的时候并没有关闭流,我倒是觉得应该你哪个地方已经关闭流了,然后还调用模板引擎渲染,这个时候就会报这个错,你的定位地方是对的,但应该是结果,你看看在渲染之前,是否你的代码关闭流了

hlmxy 2020年03月19日

好的,多谢,后续我调试一下