如何获取 freemarker 模板中使用的当前区域设置?我已经看到 <spring.message code />
的实现
我需要这个来执行条件
<#if locale = DE >
.....
<#else>
....
</#if>
最佳答案
Special variables are variables defined by the FreeMarker engine itself. To access them, you use the .variable_name syntax
.locale: Returns the current value of the locale setting. This is a string, for example en_US. For more information about locale strings see the setting directive.
因此,要访问 Freemarker 模板中的当前本地内容,您将使用
The current locale is: ${.locale}
要根据您的要求在条件语句中使用它,您可以:
<#if .locale == "DE">
...
<#else>
...
</#if>
关于spring - 在 freemarker 模板中获取区域设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19765706/