Browse Source

调整异常输出注解

master
453530270@qq.com 3 years ago
parent
commit
6b56f8a75b
  1. 6
      src/main/java/cn/chjyj/szwh/controller/GlobalErrorController.java

6
src/main/java/cn/chjyj/szwh/controller/GlobalErrorController.java

@ -4,14 +4,14 @@ import cn.chjyj.szwh.exception.ChException;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;
/** /**
* 全局异常控制器 * 全局异常控制器
*/ */
@ControllerAdvice @RestControllerAdvice
public class GlobalErrorController { public class GlobalErrorController {
//日志初始化 //日志初始化
private static final Log log = LogFactory.getLog(GlobalErrorController.class); private static final Log log = LogFactory.getLog(GlobalErrorController.class);
@ -21,7 +21,7 @@ public class GlobalErrorController {
* 异常信息输出 * 异常信息输出
* @return * @return
*/ */
@ExceptionHandler(ChException.class) @ExceptionHandler(value = ChException.class)
@ResponseBody @ResponseBody
public JSONObject aisHandler(ChException ais){ public JSONObject aisHandler(ChException ais){
log.error("Exception:"+ais); log.error("Exception:"+ais);

Loading…
Cancel
Save