Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/348.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何使用JSF和Quarkus显示自定义错误页面?_Java_Jsf_Quarkus - Fatal编程技术网

Java 如何使用JSF和Quarkus显示自定义错误页面?

Java 如何使用JSF和Quarkus显示自定义错误页面?,java,jsf,quarkus,Java,Jsf,Quarkus,我试图在JSF(myfaces版本:2.3-next-M3)中显示不同状态代码(401404500,…)的自定义错误页面。 我将Quarkus应用服务器(1.5.2.Final)与JDK 8一起使用 此时,如果发生异常,将显示默认Quarkus内部服务器错误HTML页面。如果找不到资源,应用程序服务器将显示输入的不存在资源的路径。但我想显示自己的自定义错误页面 我已经试过了: web.xml: <error-page> <error-code>404</er

我试图在JSF(myfaces版本:2.3-next-M3)中显示不同状态代码(401404500,…)的自定义错误页面。 我将Quarkus应用服务器(1.5.2.Final)与JDK 8一起使用

此时,如果发生异常,将显示默认Quarkus内部服务器错误HTML页面。如果找不到资源,应用程序服务器将显示输入的不存在资源的路径。但我想显示自己的自定义错误页面

我已经试过了:

web.xml:

<error-page>
    <error-code>404</error-code>
    <location>/error/404.xhtml</location>
</error-page>

404
/错误/404.xhtml

提供者Bean:

@Provider
public class NotFoundExceptionMapper implements ExceptionMapper<NotFoundException> {

    @Override
    public Response toResponse(NotFoundException exception) {
        String text = new Scanner(this.getClass().getResourceAsStream("/META-INF/resources/error/404.xhtml"), "UTF-8").useDelimiter("\\A").next();
        return Response.status(404).entity(text).build();
    }
}
@Provider
公共类NotFoundExceptionMapper实现ExceptionMapper{
@凌驾
公共响应(NotFoundException){
String text=new Scanner(this.getClass().getResourceAsStream(“/META-INF/resources/error/404.xhtml”),“UTF-8”).useDelimiter(“\\A”).next();
返回Response.status(404).entity(text.build();
}
}
但什么都没用。我错过什么了吗?
如何显示我的自定义错误页面?

这与quarkus无关。JSF默认不使用web.xml中的错误页。当我尝试将el解析器和异常处理程序工厂包含到我的faces配置中时,您需要一个自己的异常处理程序或@tandraschko,我在启动quarkus服务器时遇到此错误:
Class org.primefaces.application.exceptionhandler.primeexceptionhandlerlresolver未找到:java.lang.ClassNotFoundException:
那么您不使用primefaces?@tandraschko我当前使用的是primefaces 8.0以及primefaces扩展。我的完整UI依赖于primefaces UI组件。如果我通过IDE查找PrimeExceptionHandlerELResolver,我甚至可以自己找到它。你能尝试在myfaces quarkus showcase中复制它吗?这与quarkus没有真正的关系。JSF默认不使用web.xml中的错误页。当我尝试将el解析器和异常处理程序工厂包含到我的faces配置中时,您需要一个自己的异常处理程序或@tandraschko,我在启动quarkus服务器时遇到此错误:
Class org.primefaces.application.exceptionhandler.primeexceptionhandlerlresolver未找到:java.lang.ClassNotFoundException:
那么您不使用primefaces?@tandraschko我当前使用的是primefaces 8.0以及primefaces扩展。我的完整UI依赖于primefaces UI组件。如果我通过IDE查找PrimeExceptionHandlerELResolver,我甚至可以自己找到它。你能尝试在myfaces quarkus showcase中复制它吗?