设置速度属性

发布于 2024-10-02 12:00:52 字数 371 浏览 0 评论 0原文

我曾经构建过一个maven原型,我想做这样的事情

#set( $controllerPackage = ${package}\.${artifactId})

,即将controllerPackage变量设置为等于以下三个元素($package,'.',$artifactId)的字符串连接的结果,

但这显然是不正确的语法- 我明白了

词法错误:org.apache.velocity.runtime.parser.TokenMgrError:第 4 行第 40 列出现词法错误。遇到:“。” (46),之后:“\”

有没有办法可以在输出字符串中包含句点?

I have occurence building a maven archetype where I want to do something like this

#set( $controllerPackage = ${package}\.${artifactId})

i.e. set the controllerPackage variable to equal the result of string concatentaion of the following three elements ($package,'.',$artifactId)

However this is obvioulsy not correct syntax - I get this

Lexical error: org.apache.velocity.runtime.parser.TokenMgrError: Lexical error at line 4, column 40. Encountered: "." (46), after : "\"

Is there a way I can include a period in my outputted string?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

卷耳 2024-10-09 12:00:52

要构造字符串,请使用引号。

#set( $controllerPackage = "${package}.${artifactId}" )

To construct a string, use quotes.

#set( $controllerPackage = "${package}.${artifactId}" )
夜还是长夜 2024-10-09 12:00:52

您可以使用 + 进行字符串连接:

#set( $controllerPackage = ${package} + "." + ${artifactId})

You can use + for string concatenation:

#set( $controllerPackage = ${package} + "." + ${artifactId})
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文