/**
 * Company Name : 中贸促信息技术有限责任公司	
 * Project Name:investWebsite
 * File Name:MyMultipartResolver.java
 * Package Name:ccpit.base.controller
 * Date:2016年7月15日上午10:25:21
 * Copyright (c) 2016, liyang@ccpit.org All Rights Reserved.
 *
 */
package org.ccpit.base.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Repository;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;

/**
 * ClassName: MyMultipartResolver <br/>
 * Function: TODO ADD FUNCTION. <br/>
 * Reason: TODO ADD REASON(可选). <br/>
 * date: 2016年7月15日 上午10:25:21 <br/>
 *
 * @author liyang
 * @version 
 * @since JDK 1.6
 */
public class MyMultipartResolver extends CommonsMultipartResolver {
	private String excludeUrls;   
	//配置自己的url
    private String[] excludeUrlArray = {};  
      
    public String getExcludeUrls() {  
        return excludeUrls;  
    }  
  
  
    public void setExcludeUrls(String excludeUrls) {  
        this.excludeUrls = excludeUrls;  
        this.excludeUrlArray = excludeUrls.split(",");  
    }  
  
  
    /** 
     * 这里是处理Multipart http的方法。如果这个返回值为true,那么Multipart http body就会MyMultipartResolver 消耗掉.如果这里返回false 
     * 那么就会交给后面的自己写的处理函数处理例如刚才ServletFileUpload 所在的函数 
     * @see org.springframework.web.multipart.commons.CommonsMultipartResolver#isMultipart(javax.servlet.http.HttpServletRequest) 
     */  
    @Override  
    public boolean isMultipart(HttpServletRequest request) {  
        for (String url: excludeUrlArray) {          // 这里可以自己换判断  
            if (request.getRequestURI().contains(url)) {  
                return false;  
            }  
        }  
          
        return super.isMultipart(request);  
    }  
}
