From f50d7e85c0503ce96530f765c577f87a93ff07d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90Li?= <15040126243@163.com> Date: Wed, 25 Jun 2025 10:16:43 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=BC=98=E5=8C=96=20=E5=85=A8?= =?UTF-8?q?=E5=B1=80=E6=97=A5=E6=9C=9F=E6=A0=BC=E5=BC=8F=E8=BD=AC=E6=8D=A2?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=EF=BC=8C=E6=8F=90=E5=8D=87=E6=97=A5=E6=9C=9F?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E8=A7=A3=E6=9E=90=E5=85=BC=E5=AE=B9=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/web/config/ResourcesConfig.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ruoyi-common/ruoyi-common-web/src/main/java/org/dromara/common/web/config/ResourcesConfig.java b/ruoyi-common/ruoyi-common-web/src/main/java/org/dromara/common/web/config/ResourcesConfig.java index 8803dca7..8dbb589d 100644 --- a/ruoyi-common/ruoyi-common-web/src/main/java/org/dromara/common/web/config/ResourcesConfig.java +++ b/ruoyi-common/ruoyi-common-web/src/main/java/org/dromara/common/web/config/ResourcesConfig.java @@ -1,12 +1,17 @@ package org.dromara.common.web.config; +import cn.hutool.core.date.DateUtil; +import org.dromara.common.core.utils.StringUtils; import org.dromara.common.web.handler.GlobalExceptionHandler; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.context.annotation.Bean; +import org.springframework.format.FormatterRegistry; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import java.util.Date; + /** * 通用配置 * @@ -20,6 +25,17 @@ public class ResourcesConfig implements WebMvcConfigurer { } + @Override + public void addFormatters(FormatterRegistry registry) { + // 全局日期格式转换配置 + registry.addConverter(String.class, Date.class, source -> { + if (StringUtils.isBlank(source)) { + return null; + } + return DateUtil.parse(source); + }); + } + @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { }