gpt4 book ai didi

amazon-web-services - 在 Apache Velocity 模板语言中追加字符串变量

转载 作者:行者123 更新时间:2023-12-05 03:51:08 25 4
gpt4 key购买 nike

我想在 API 网关映射模板中构造查询字符串。我有这样的东西

#foreach($entry in $entries)
#set($count = $foreach.count)
#set($entriesQueryString = "$!{entriesQueryString}Id=${count}&"
#end

想法是只要输入中提供了条目就追加新字符串。

我的代码有效吗?还有其他方法可以追加吗?

最佳答案

根据 this postVTL user guide page ,连接的方式只是通过“将项目放在一起”。来自 VTL 指南:

A common question that developers ask is How do I do String concatenation? Is there any analogue to the '+' operator in Java?.To do concatenation of references in VTL, you just have to 'put them together'. The context of where you want to put them together does matter, so we will illustrate with some examples.In the regular 'schmoo' of a template (when you are mixing it in with regular content) :

#set( $size = "Big" )
#set( $name = "Ben" )
The clock is $size$name.

所以我想这是唯一的方法。

关于amazon-web-services - 在 Apache Velocity 模板语言中追加字符串变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63180693/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com