如何在Spring Boot错误页面声明中使用FullAjaxExceptionHandler? [英] How to use FullAjaxExceptionHandler with Spring Boot error page declarations?

查看:72
本文介绍了如何在Spring Boot错误页面声明中使用FullAjaxExceptionHandler?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Spring Boot应用程序中使用onmifaces时,我们该怎么办?错误页面的声明是在EmbeddedServletContainerCustomizer类上进行的?

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"));
}

我已经分析化了findErrorPageLocation,它使用了WebXml来解析web.xml文件.

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

推荐答案

当前版本的Servlet API可以

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不支持并且不支持Spring特定的API.我建议仅继续使用web.xml进行错误页面配置,以便非Spring库能够共享它们.

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.

这篇关于如何在Spring Boot错误页面声明中使用FullAjaxExceptionHandler?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆