您的位置:首页 > 运维架构 > Tomcat

springboot项目打包部署外部Tomcat访问页面时出现ErrorPageFilter异常

2019-06-20 11:27 981 查看

将springboot项目打包部署到外部tomcat后,访问页面时png、js等资源404,

错误如下(部分):

org.apache.catalina.connector.ClientAbortException: java.io.IOException: 断开的管道
at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:356)
at org.apache.catalina.connector.OutputBuffer.flushByteBuffer(OutputBuffer.java:815)
at org.apache.catalina.connector.OutputBuffer.append(OutputBuffer.java:720)
at org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:391)
at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:369)
at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:96)
at org.springframework.util.StreamUtils.copy(StreamUtils.java:138)

报错:
2019-06-19 21:26:39.454 ERROR 2431 — [io-8888-exec-23] o.s.boot.web.support.ErrorPageFilter : Cannot forward to error page for request [/static/js/echarts.js] as the response has already been committed. As a result, the response may have the wrong status code. If your application is running on WebSphere Application Server you may be able to resolve this problem by setting com.ibm.ws.webcontainer.invokeFlushAfterService to false

翻译一下:
请求这个链接或者资源时,已经提前被响应了…

解决方案:
在springboot启动类中加入如下代码:

//解决ErrorPageFilter错误
@Bean
public ErrorPageFilter errorPageFilter(){
return new ErrorPageFilter();
}
@Bean
public FilterRegistrationBean disableSpringBootErrorFilter(ErrorPageFilter filter) {
FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
filterRegistrationBean.setFilter(filter);
filterRegistrationBean.setEnabled(false);
return filterRegistrationBean;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: