From 177249c76aeea0b4bf8d8816d4994e3b445b45ce Mon Sep 17 00:00:00 2001 From: huanghongfa <huanghongfa123456> Date: 星期四, 02 九月 2021 10:39:34 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/zzj' into zzj --- springcloud_k8s_panzhihuazhihuishequ/zuul/src/main/java/com/panzhihua/zuul/handles/FileUploadExceptionAdvice.java | 27 ++++++++++++--------------- 1 files changed, 12 insertions(+), 15 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/zuul/src/main/java/com/panzhihua/zuul/handles/FileUploadExceptionAdvice.java b/springcloud_k8s_panzhihuazhihuishequ/zuul/src/main/java/com/panzhihua/zuul/handles/FileUploadExceptionAdvice.java index 970ce9f..ed11f48 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/zuul/src/main/java/com/panzhihua/zuul/handles/FileUploadExceptionAdvice.java +++ b/springcloud_k8s_panzhihuazhihuishequ/zuul/src/main/java/com/panzhihua/zuul/handles/FileUploadExceptionAdvice.java @@ -1,25 +1,24 @@ package com.panzhihua.zuul.handles; -import com.panzhihua.common.constants.HttpStatus; -import com.panzhihua.common.model.vos.R; -import com.panzhihua.common.utlis.ResultUtil; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + import org.apache.tomcat.util.http.fileupload.impl.FileSizeLimitExceededException; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.multipart.MaxUploadSizeExceededException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import com.panzhihua.common.constants.HttpStatus; +import com.panzhihua.common.model.vos.R; +import com.panzhihua.common.utlis.ResultUtil; @ControllerAdvice public class FileUploadExceptionAdvice { @ExceptionHandler(MaxUploadSizeExceededException.class) - public void handleMaxSizeException( - MaxUploadSizeExceededException exc, - HttpServletRequest request, - HttpServletResponse response) { - //请求超过大小限制 + public void handleMaxSizeException(MaxUploadSizeExceededException exc, HttpServletRequest request, + HttpServletResponse response) { + // 请求超过大小限制 response.setContentType("application/json;charset=utf-8"); ResultUtil.responseJson(response, R.fail(HttpStatus.REQUEST_TOO_LARGE, "请求主体的大小超过限制")); return; @@ -27,11 +26,9 @@ } @ExceptionHandler(FileSizeLimitExceededException.class) - public void handleFileSizeLimitException( - FileSizeLimitExceededException exc, - HttpServletRequest request, - HttpServletResponse response) { - //请求超过大小限制 + public void handleFileSizeLimitException(FileSizeLimitExceededException exc, HttpServletRequest request, + HttpServletResponse response) { + // 请求超过大小限制 response.setContentType("application/json;charset=utf-8"); ResultUtil.responseJson(response, R.fail(HttpStatus.REQUEST_TOO_LARGE, "文件大小超过限制")); return; -- Gitblit v1.7.1