In Spring i need to show message in my ftl file. i am using
<@spring.message "property_name">
and the message comes from my properties file.
i need the mssage like
"Message_content_link"
the test link will be a url which will point to another page. i tried like
properties file
message_content=Message_content
message_link=link
ftl file
<@spring.message "message_content" htmlEscaspe="false"><a href="#url_page"><@spring.message "message_link"></a>
FreeMarker now includes the option to expose the Spring Macro Helpers. In your WebMVC config, add resolver.setExposeSpringMacroHelpers(true);
Now in your *.ftl file, you can call springMacroRequestContext.getMessage(code, argsArray, "", escapeHtml)
You can then just assign this to a shorthand function:
<#function msg code args=[] escapeHtml=true>
<#local argsArray = [] />
<#if args?is_string>
<#local argsArray = [args] />
<#elseif args?is_sequence>
<#local argsArray = args />
<#else>
<#return "" />
</#if>
<#return springMacroRequestContext.getMessage(code, argsArray, "", escapeHtml) />
</#function>
See an example here: https://github.com/edendramis/freemarker-example/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.