简体   繁体   中英

Is it possible to pass just a String as the data-model for a FreeMarker template?

I want to use pass to a FreeMarker template just one variable, ie some text, eg "this is a text" ; is it possible to pass one String only as the model variable instead of packing it into an object or a Map? What would look like the FreeMarker template using the String variable?

PS: should work with Java

The variables exposed to the template must have a name. Even if you only have one variable. How would you refer to that value in the template otherwise? Like Hello ${whatWillBeHere}! ?

Well, based on my own experience confirmed here in the comments I conclude that the answer is: it is not possible to pass one String only as the model variable instead of packing it into an object or a Map .

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM