joinfaces: Best practices for error page mapping in joinfaces
Hello,
we’re developing a web application with embedded tomcat, spring-boot (no mvc) and joinfaces. We don’t have a web.xml nor a web-fragment.xml, so error page mapping is a bit difficult. We implemented error mapping as a @Bean annotated method in a @Configuration class.
E.g.:
@Bean
public ErrorPageRegistrar errorPageRegistrar() {
return new ErrorPageRegistrar() {
@Override
public void registerErrorPages(ErrorPageRegistry registry) {
registry.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, errorPage));
registry.addErrorPages(new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, errorPage));
}
};
}
Where errorPage is a static variable that points to the error file. Classes like FacesExceptionFilter or FullAjaxExceptionHandler from Omnifaces unfortunately do not work (since we do not have a web.xml).
So is this approach really the best way to implement error page mapping in joinfaces or is there a better solution available?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 1
- Comments: 15 (3 by maintainers)
Hi slamalotfi1987,
sure. First set up a configuration class and add a mapping method like the following:
yourErrorPageshould point to a XHTML file, which should be displayed, when the error occurred (for example in META-INF/resources/error/error.xhtml). Sorry for the bad formatting of the code.