前端用thymeleaf模板引擎,获取参数的时候,如果没有参数就会报500错误,返回给前端很不好,如何自定义500页面
<h1 id="title" align="center" style="overflow:hidden;white-space:normal;word-break:break-all" th:text="${news.title}" th:value="${news.id}"></h1>
试过下面这种方法,thymeleaf报的500异常无法跳转到自定义500页面
@Configuration
public class ErrorPageConfig implements ErrorPageRegistrar {
@Override
public void registerErrorPages(ErrorPageRegistry registry) {
ErrorPage e404 = new ErrorPage(HttpStatus.NOT_FOUND, "/404");
ErrorPage e500 = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/500");
registry.addErrorPages(e404,e500);
}
}
ErrorController接口,springboot用这个接口快多了