Spring 更改thymeleaf实用程序对象的区域设置
我想使用日期或日历来获取当前年份已过去月份的列表。这可以使用${dates.monthNamedate}和一些逻辑来实现,但是月份的名称是英文的,我需要西班牙文的 有没有办法告诉thymeleaf使用一种或另一种语言环境?我已经读到它使用Java中的标准日期和日历,因此可能在spring中为此类设置某种应用程序会起作用?您必须使用monthNameObject target方法,即Thymeleaf的Locale。 我认为这样做应该奏效: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
${T(org.thymeleaf.util.DateUtils).monthName(#dates.createNow(), #locale.getDefault())}
它将从Spring运行的区域设置中进行选择。我用我们的一个应用程序验证了这一点。如果您需要关于我们如何进行区域设置管理的更多信息,我可以在下面的答案中共享代码