thymeleaf获取不到参数报500错误如何跳转到自定义错误页面?
前端用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);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

ErrorController接口,springboot用这个接口快多了