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
Yes, you can pass any Object
to the template process
method:
See also: https://freemarker.apache.org/docs/pgui_quickstart_all.html
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.