pet*_*hel 4 spring freemarker spring-mvc
如何获取freemarker模板中使用的当前区域设置?我见过实施<spring.message code />
我需要这个做有条件的
<#if locale = DE >
.....
<#else>
....
</#if>
Run Code Online (Sandbox Code Playgroud)
特殊变量是FreeMarker引擎本身定义的变量.要访问它们,请使用.variable_name语法
.locale:返回语言环境设置的当前值.这是一个字符串,例如en_US.有关区域设置字符串的更多信息,请参阅setting指令.
因此,要访问Freemarker模板中的当前本地,您将使用
The current locale is: ${.locale}
Run Code Online (Sandbox Code Playgroud)
要根据您的要求在条件语句中使用它,您可以:
<#if .locale == "DE">
...
<#else>
...
</#if>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3106 次 |
| 最近记录: |