1、返回自定义异常界面,需要引入thymeleaf依赖
        <dependency>
           <groupId>org.springframework.boot</groupId>
           <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>


    2、resource目录下新建templates,并新建error.html
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("error.html");
        modelAndView.addObject("msg", e.getMessage());
        return modelAndView;

 

SpringBoot2.x配置全局异常返回自定义页面

 

SpringBoot2.x配置全局异常返回自定义页面

 

SpringBoot2.x配置全局异常返回自定义页面

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-31
  • 2021-11-21
  • 2021-12-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-01
  • 2021-11-20
  • 2021-06-14
  • 2021-09-13
  • 2021-12-21
  • 2021-09-26
  • 2022-12-23
相关资源
相似解决方案