zoukankan      html  css  js  c++  java
  • 【09-27】Spring 学习笔记

    SpringMVC 配置全局异常处理器

    import javax.servlet.http.HttpServletResponse;
    
    import org.springframework.web.bind.annotation.ControllerAdvice;
    import org.springframework.web.bind.annotation.ExceptionHandler;
    import org.springframework.web.bind.annotation.ResponseBody;
    
    /**
     * 配置全局SpringMVC异常处理方法,该类应该配置SpringMVC能够扫描的包中
     */
    @ControllerAdvice
    public class GlobalExceptionHandler {
    	@ResponseBody
    	@ExceptionHandler(Exception.class)
    	public String handleException(Exception e, HttpServletResponse response) {
    		response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    		return e.getMessage();
    	}
    
    }
    
  • 相关阅读:
    PowerDesigner11.0的SQL生成表,写列描述出错
    centos中crontab(计时器)用法详解
    5.14
    4.13
    5.15
    监听服务启动失败
    4.24
    Enjoy 4.26
    4.14
    export
  • 原文地址:https://www.cnblogs.com/achievec/p/5914731.html
Copyright © 2011-2022 走看看