Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring 更改thymeleaf实用程序对象的区域设置_Spring_Spring Boot_Localization_Thymeleaf - Fatal编程技术网

Spring 更改thymeleaf实用程序对象的区域设置

Spring 更改thymeleaf实用程序对象的区域设置,spring,spring-boot,localization,thymeleaf,Spring,Spring Boot,Localization,Thymeleaf,我想使用日期或日历来获取当前年份已过去月份的列表。这可以使用${dates.monthNamedate}和一些逻辑来实现,但是月份的名称是英文的,我需要西班牙文的 有没有办法告诉thymeleaf使用一种或另一种语言环境?我已经读到它使用Java中的标准日期和日历,因此可能在spring中为此类设置某种应用程序会起作用?您必须使用monthNameObject target方法,即Thymeleaf的Locale。 我认为这样做应该奏效: ${T(org.thymeleaf.util.DateU

我想使用日期或日历来获取当前年份已过去月份的列表。这可以使用${dates.monthNamedate}和一些逻辑来实现,但是月份的名称是英文的,我需要西班牙文的

有没有办法告诉thymeleaf使用一种或另一种语言环境?我已经读到它使用Java中的标准日期和日历,因此可能在spring中为此类设置某种应用程序会起作用?

您必须使用monthNameObject target方法,即Thymeleaf的Locale。 我认为这样做应该奏效:

${T(org.thymeleaf.util.DateUtils).monthName(#dates.createNow(), #locale.getDefault())}

它将从Spring运行的区域设置中进行选择。我用我们的一个应用程序验证了这一点。如果您需要关于我们如何进行区域设置管理的更多信息,我可以在下面的答案中共享代码