Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

CavaliersFor/web_config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

5 Commits

Repository files navigation

Spring Boot项目全局错误处理包含页面和API的统一错误处理

  • 配置项目异常统一处理方法和返回页面

支持thymeleaf

这里使用thymeleaf示例,在类com.knight.configdemo.config.WebMVCConfig中是配置thymeleaf的相关配置都是模板代码。 WebMVCConfig

定义API响应风格

通过自定义类实现,在类com.knight.configdemo.base.ApiResponse中实现,AppErrorController

web错误全局处理Controller

在spring boot中通过实现类org.springframework.boot.autoconfigure.web.ErrorController处理全局错误;详情见类com.knight.configdemo.base.AppErrorController 在上面的类中配置错误页面处理和API接口处理 AppErrorController

添加异常页面

properties文件中已经配置了thymeleaf的路径,在templates目录下新建404.html、403.html、500.html文件 templates

About

web项目全局错误处理包含页面和API的统一错误处理

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

Contributors

AltStyle によって変換されたページ (->オリジナル) /