1. 程式人生 > >解決grails上傳圖片大小過大報錯問題

解決grails上傳圖片大小過大報錯問題

Class org.apache.tomcat.util.http.fileupload.FileUploadBase$SizeLimitExceededException Message

Request processing failed; nested exception is org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; nested exception is java.lang.IllegalStateException: org.apache.tomcat.util.http.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (288940) exceeds the configured maximum (128000)

解決方法:
1、開啟檔案:xxx\grails-app\conf\spring\resources.groovy

2、匯入CommonsMultipartResolver需要的jar包


3、寫上以下程式碼即可
// Place your Spring DSL code here
import org.springframework.web.multipart.commons.CommonsMultipartResolver
beans = {


//  預設上傳檔案大小
    multipartResolver(CommonsMultipartResolver){
        maxUploadSize = 41943040

// 40MB
        maxInMemorySize = 41943040
        defaultEncoding = "utf-8"
    }


}