File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change 4
4
5
5
** 1. 新建异常信息实体类**
6
6
7
- 非必要的类,主要用于包装将异常信息 。
7
+ 非必要的类,主要用于包装异常信息 。
8
8
9
9
` src/main/java/com/twuc/webApp/exception/ErrorResponse.java `
10
10
@@ -65,7 +65,7 @@ public class ResourceNotFoundException extends RuntimeException {
65
65
66
66
** 3. 新建异常处理类**
67
67
68
- 我们只需要在类上加上` @ControllerAdvice ` 注解这个类就成为了全局异常处理类,当然你也可以通过 ` assignableTypes ` 指定特定的类 ,让异常处理类只处理特定类抛出的异常。
68
+ 我们只需要在类上加上` @ControllerAdvice ` 注解这个类就成为了全局异常处理类,当然你也可以通过 ` assignableTypes ` 指定特定的 ` Controller ` 类 ,让异常处理类只处理特定类抛出的异常。
69
69
70
70
` src/main/java/com/twuc/webApp/exception/GlobalExceptionHandler.java `
71
71
@@ -177,7 +177,7 @@ public class ExceptionTest {
177
177
178
178
### 3. ResponseStatusException
179
179
180
- 研究 ResponseStatusException 我们先来看看,通过 ` ResponseStatus ` 注解简单处理异常的方法。
180
+ 研究 ResponseStatusException 我们先来看看,通过 ` ResponseStatus ` 注解简单处理异常的方法(将异常映射为状态码) 。
181
181
182
182
` src/main/java/com/twuc/webApp/exception/ResourceNotFoundException.java `
183
183
You can’t perform that action at this time.
0 commit comments