You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
/**
* 文件名 : BaseController.java
* 版权 : XX科技有限公司。
* 描述 : <描述>
* 修改时间: 2016年9月7日
* 修改内容:<修改内容>
*/
package com.base ;
import javax.servlet.http.HttpServletRequest ;
import org.springframework.web.bind.annotation.ExceptionHandler ;
/**
* <一句话功能简述>
* <功能详细描述>
* @author chen
* @version [版本号, 2016年9月7日]
* @see [相关类/方法]
* @since [产品/模块版本]
*/
public class BaseController {
/**
* <一句话功能简述> 基于@ExceptionHandler异常处理----全局异常处理
* <功能详细描述>
* @param request
* @param ex 异常
* @return
* @see [类、类#方法、类#成员]
*/
@ExceptionHandler
public String exp ( HttpServletRequest request , Exception ex ) {
request . setAttribute ( "ex" , ex ) ;
System . err . println ( "BaseController --exp " ) ;
// 根据不同错误转向不同页面
if ( ex instanceof CustomException ) {
//TODO 从新封装json
System . err . println ( "BaseController --exp -- CustomException " ) ;
return "error-business" ;
} else {
//TODO 其他错误则 调到指定页面
return "error" ;
}
}
}