SpringBoot 启动报错:Cannot forward to error page for request [/] as the response has already been commit
**SpringBoot 启动报错:Cannot forward to error page for request [/] as the response has already been committed. As a result解决方法注册错误页面并通过过滤请求并转发到错误页面来处理应用程序错误,而不是让服务器来处理它们。在SpringBoot启动类中加入:@Beanpublic Erro
·
SpringBoot 启动报错:Cannot forward to error page for request [/] as the response has already been committed. As a result
解决方法
注册错误页面并通过过滤请求并转发到错误页面来处理应用程序错误,而不是让服务器来处理它们。
在SpringBoot启动类中加入:
@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;
}
更多推荐
已为社区贡献3条内容
所有评论(0)