Commit 4657b1918d5ddc075c2c32c28c76f73bc3bb07ec
Committed by
Gitee
!97 修改上传文件大小限制值,出参错误提示显示动态大小参数。
Merge pull request !97 from 云飞扬/N/A
Showing
1 changed file
with
4 additions
and
2 deletions
jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/JeecgBootExceptionHandler.java
... | ... | @@ -4,6 +4,7 @@ import io.lettuce.core.RedisConnectionException; |
4 | 4 | import org.apache.shiro.authz.AuthorizationException; |
5 | 5 | import org.apache.shiro.authz.UnauthorizedException; |
6 | 6 | import org.jeecg.common.api.vo.Result; |
7 | +import org.springframework.beans.factory.annotation.Value; | |
7 | 8 | import org.springframework.dao.DataIntegrityViolationException; |
8 | 9 | import org.springframework.dao.DuplicateKeyException; |
9 | 10 | import org.springframework.data.redis.connection.PoolException; |
... | ... | @@ -26,7 +27,8 @@ import lombok.extern.slf4j.Slf4j; |
26 | 27 | @RestControllerAdvice |
27 | 28 | @Slf4j |
28 | 29 | public class JeecgBootExceptionHandler { |
29 | - | |
30 | + @Value("${spring.servlet.multipart.max-file-size}") | |
31 | + private String maxFileSize; | |
30 | 32 | /** |
31 | 33 | * 处理自定义异常 |
32 | 34 | */ |
... | ... | @@ -100,7 +102,7 @@ public class JeecgBootExceptionHandler { |
100 | 102 | @ExceptionHandler(MaxUploadSizeExceededException.class) |
101 | 103 | public Result<?> handleMaxUploadSizeExceededException(MaxUploadSizeExceededException e) { |
102 | 104 | log.error(e.getMessage(), e); |
103 | - return Result.error("文件大小超出10MB限制, 请压缩或降低文件质量! "); | |
105 | + return Result.error(String.format("文件大小超出%s限制, 请压缩或降低文件质量! ", maxFileSize)); | |
104 | 106 | } |
105 | 107 | |
106 | 108 | @ExceptionHandler(DataIntegrityViolationException.class) |
... | ... |