chao 4 years ago
parent
commit
5bcf736992
1 changed files with 3 additions and 0 deletions
  1. 3 0
      src/main/java/com/caimei/www/config/CustomExceptionHandler.java

+ 3 - 0
src/main/java/com/caimei/www/config/CustomExceptionHandler.java

@@ -2,6 +2,8 @@ package com.caimei.www.config;
 
 import org.springframework.web.bind.annotation.ControllerAdvice;
 import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.ResponseBody;
 import reactor.core.publisher.Mono;
 
 /**
@@ -21,6 +23,7 @@ public class CustomExceptionHandler {
     }
 
     @ExceptionHandler(IllegalAccessException.class)
+    @ResponseBody
     public Mono<String> convertIllegalAccessError(Exception e) {
         //自定义逻辑,可返回其他值
         return Mono.just("illegal access");