// Path: src/main/java/com/baicai/core/BusinessException.java
// public class BusinessException extends Exception {
// 	private static final long serialVersionUID = 1L;
// 	
// 	public BusinessException() {   
//     }  
//   
//     public BusinessException(String message) {  
//         super(message);  
//     }  
//   
//     public BusinessException(Throwable cause) {  
//         super(cause);   
//     }  
//   
//     public BusinessException(String message, Throwable cause) {  
//         super(message, cause);  
//     }  
//     
//     @Override
//     public Throwable fillInStackTrace() {
//     	return null;
//     }
// 
// }


import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
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 com.alibaba.fastjson.JSON;
import com.baicai.core.BusinessException; 

package com.baicai.controller.common;
/**
 * 全局异常处理，注意这里只能对contoller里抛出的异常进行拦截处理，其他的异常这里拦截不到
* @Description: TODO
* @author 猪肉有毒 waitfox@qq.com  
* @date 2016年4月7日 下午11:03:18 
* @version V1.0  
* 我只为你回眸一笑，即使不够倾国倾城，我只为你付出此生，换来生再次相守
 */
@ControllerAdvice
public class ExceptionControllerAdvice {
	private Logger log=LoggerFactory.getLogger(ExceptionControllerAdvice.class);
	
	@ExceptionHandler
    public String expAdvice(HttpServletRequest request, HttpServletResponse response, Exception ex){
        ex.printStackTrace();
        Map<String, Object> map = new HashMap<String, Object>();
        if (!(request.getHeader("accept").indexOf("application/json") > -1 || (request
                .getHeader("X-Requested-With") != null && request.getHeader(
                "X-Requested-With").indexOf("XMLHttpRequest") > -1))) {
        	// 如果不是ajax，返回页面       	
            map.put("success", false);

// Path: src/main/java/com/baicai/core/BusinessException.java
// public class BusinessException extends Exception {
// 	private static final long serialVersionUID = 1L;
// 	
// 	public BusinessException() {   
//     }  
//   
//     public BusinessException(String message) {  
//         super(message);  
//     }  
//   
//     public BusinessException(Throwable cause) {  
//         super(cause);   
//     }  
//   
//     public BusinessException(String message, Throwable cause) {  
//         super(message, cause);  
//     }  
//     
//     @Override
//     public Throwable fillInStackTrace() {
//     	return null;
//     }
// 
// }


// Path: src/main/java/com/baicai/controller/common/ExceptionControllerAdvice.java
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
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 com.alibaba.fastjson.JSON;
import com.baicai.core.BusinessException; 

package com.baicai.controller.common;
/**
 * 全局异常处理，注意这里只能对contoller里抛出的异常进行拦截处理，其他的异常这里拦截不到
* @Description: TODO
* @author 猪肉有毒 waitfox@qq.com  
* @date 2016年4月7日 下午11:03:18 
* @version V1.0  
* 我只为你回眸一笑，即使不够倾国倾城，我只为你付出此生，换来生再次相守
 */
@ControllerAdvice
public class ExceptionControllerAdvice {
	private Logger log=LoggerFactory.getLogger(ExceptionControllerAdvice.class);
	
	@ExceptionHandler
    public String expAdvice(HttpServletRequest request, HttpServletResponse response, Exception ex){
        ex.printStackTrace();
        Map<String, Object> map = new HashMap<String, Object>();
        if (!(request.getHeader("accept").indexOf("application/json") > -1 || (request
                .getHeader("X-Requested-With") != null && request.getHeader(
                "X-Requested-With").indexOf("XMLHttpRequest") > -1))) {
        	// 如果不是ajax，返回页面       	
            map.put("success", false);

            if (ex instanceof BusinessException) {
