速度变量(同时使用字符串和整数变量) [英] Velocity Variable(use together string and integer variables)

查看:38
本文介绍了速度变量(同时使用字符串和整数变量)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Velocity"中同时使用字符串和整数变量?

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

我尝试了几次,但我不能.

I tried a few times but I could not.

任何帮助将不胜感激.

推荐答案

如果您尝试进行连接,Velocity 不支持它,甚至不支持 2 个字符串.相反,您应该使用字符串插值.示例:

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.

这篇关于速度变量(同时使用字符串和整数变量)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆