我知道你可以通过使用它来处理多部分文件异常.
@ControllerAdvice public class MyErrorController extends ResponseEntityExceptionHandler { Logger logger = org.slf4j.LoggerFactory.getLogger(getClass()); @ExceptionHandler(MultipartException.class) @ResponseBody String handleFileException(HttpServletRequest request, Throwable ex) { //return your json insted this string. return "File upload error"; } }