我正在创建一个应该在tomcat上运行的soap服务.
我正在为我的应用程序使用 spring-boot,类似于:
我正在为我的应用程序使用 spring-boot,类似于:
@Configuration @EnableAutoConfiguration(exclude = ErrorMvcAutoConfiguration.class) public class AppConfig { }
我的webservice(示例):
@Component @WebService public class MyWebservice { @WebMethod @WebResult public String test() { throw new MyException(); } } @WebFault public class MyException extends Exception { }
问题:无论何时在webservice类中引发异常,服务器上都会记录以下消息:
ErrorPageFilter: Cannot forward to error page for request
[/services/MyWebservice] 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
问题:我该如何防范?
解决方法
要在Spring Boot中禁用ErrorPageFilter(使用1.3.0.RELEASE进行测试),请将以下bean添加到Spring配置中:
@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; }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。