WEB项目异常处理

package cn.rest.advice;

import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

import cn.rest.exception.BaseException;
/**
 *
 * 〈一句话功能简述〉<br>
 * 统一异常处理--将异常打印到日志
 *
 */

@ControllerAdvice
public class GlobalExceptionLog {
    
    private final Logger logger = LoggerFactory.getLogger(GlobalExceptionLog.class);

    
    @ExceptionHandler(BaseException.class)
    public void exceptionHandler(BaseException e, HttpServletResponse response) {
        logger.error(e.getMessage(),e);
    }
}

posted @ 2017-05-31 10:17  夏嘻嘻嘻嘻嘻  阅读(195)  评论(0编辑  收藏  举报