How to use FullAjaxExceptionHandler with Spring Boot error page declarations?

笑着哭i 提交于 2019-12-13 09:12:45

问题


How can we do when use onmifaces in the case of spring boot apps?, where the error pages declaration is made at EmbeddedServletContainerCustomizer class?

@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
    MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT);

    mappings.add("eot", "application/vnd.ms-fontobject");
    mappings.add("ttf", "application/x-font-ttf");
    mappings.add("woff", "application/x-font-woff");
    mappings.add("woff2", "application/x-font-woff2");

    container.setMimeMappings(mappings);

    container.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/error.xhtml"));
    container.addErrorPages(new ErrorPage(FaceletException.class, "/error.xhtml"));
    container.addErrorPages(new ErrorPage(Throwable.class, "/error.xhtml"));
}

I have analized findErrorPageLocation and it uses WebXml that parses web.xml files.


回答1:


The Servlet API in its current version does not support programmatically defining and obtaining error pages. That's why OmniFaces had to manually parse web.xml.

OmniFaces does not and will not support Spring specific APIs. I recommend to just keep using web.xml for error page configuration so that non-Spring libraries will be able to share them.



来源:https://stackoverflow.com/questions/42022302/how-to-use-fullajaxexceptionhandler-with-spring-boot-error-page-declarations

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!