- 问题描述
在使用maven打包(package)springboot项目为war项目后,在本地机器上使用Tomcat跑这个项目,访问资源时出现下面的错误:
o.s.b.w.servlet.support.ErrorPageFilter : Cannot forward to error page
for request [/test] 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
参考了很多办法,有说在启动类中添加如下代码可以解决:
@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;
}
还有包括在pom文件中注释掉内嵌的Tomcat依赖的解决办法。
但是我尝试无果。
- 解决办法
引入文件的话,一定要记得将resources目录下的文件引入到类路径下:
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**
- 参考引用
https://blog.csdn.net/ljf12138/article/details/117786285
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)