Spring mvc 如何通过FreeMarker中的属性文件加载标签
我正在使用SpringMVC+FreeMarker集成。由于我是FreeMarker的新手,我无法找到从属性文件配置FreeMarker标签的方法 请帮我解决这个问题Spring mvc 如何通过FreeMarker中的属性文件加载标签,spring-mvc,freemarker,labels,Spring Mvc,Freemarker,Labels,我正在使用SpringMVC+FreeMarker集成。由于我是FreeMarker的新手,我无法找到从属性文件配置FreeMarker标签的方法 请帮我解决这个问题 谢谢。您可以为此使用“ResourceBundleMessageSource”消息源 <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource" <
谢谢。您可以为此使用“ResourceBundleMessageSource”消息源
<bean id="messageSource"
class="org.springframework.context.support.ResourceBundleMessageSource"
<property name="basename" value="classpath:messages/messages" />
<property name="defaultEncoding" value="UTF-8"/>
/>
定义区域设置解析器
<bean id="localeResolver"
class="org.springframework.web.servlet.i18n.SessionLocaleResolver">
<property name="defaultLocale" value="en" />
</bean>
定义localeChangeInterceptor,它从用户会话检测语言参数并调用LocaleResolve。并在处理程序映射中注册拦截器
<bean id="localeChangeInterceptor"
class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
<property name="paramName" value="lang" />
</bean>
class=“org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping”>
属性文件需要定义如下:
- 消息属性
- 消息属性
<#import "/spring.ftl" as spring/>
及
可以在.ftl中访问消息,如下所示
<@spring.message "customMessageKey"/>
它如何决定使用消息属性或消息属性?检查更新的答案。拦截器提供LocalResolver中使用的语言参数。
<@spring.message "customMessageKey"/>