Velocity Variable(use together string and integer variables)

試著忘記壹切 提交于 2021-01-27 22:34:32

问题


How can I use String and Integer variables it together in "Velocity"?

#set ($var1 = "exp"+1)

I tried a few times but I could not.

Any help will be highly appreciated.


回答1:


If you were trying to do concatenation, it's not supported by Velocity, not even for 2 Strings. Instead, you should use string interpolation. Example:

#set ($string = "exp")
#set ($number = 1)
#set ($interpolatedExample1 = "$string$number")
#set ($interpolatedExample2 = "${string}someStringLiteral$number")

Read more details and examples in the documentation.



来源:https://stackoverflow.com/questions/51465488/velocity-variableuse-together-string-and-integer-variables

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!