Amazon web services 车身映射模板中引用后的Dot(AWS API网关)

Amazon web services 车身映射模板中引用后的Dot(AWS API网关),amazon-web-services,aws-api-gateway,string-concatenation,vtl,apache-velocity,Amazon Web Services,Aws Api Gateway,String Concatenation,Vtl,Apache Velocity,是否可以在API网关的主体映射模板中的引用之后直接使用点 我是这样做的: #set($region = "us-east-2") #set($apiid = "$context.apiId") #set($stage = "$context.stage") #set($path = "search/stac") "url": "https://$apiid.execute-api.$region.amazonaws.com/$stage/$path" 问题是$APID和$region没有被取

是否可以在API网关的主体映射模板中的引用之后直接使用点

我是这样做的:

#set($region = "us-east-2")
#set($apiid = "$context.apiId")
#set($stage = "$context.stage")
#set($path = "search/stac")

"url": "https://$apiid.execute-api.$region.amazonaws.com/$stage/$path"
问题是$APID和$region没有被取消引用。结果是这样的

"url: "https:// .execute-api. .amazonaws.com/dev/search/stac
如果使用不带字符串连接的引用,则它们具有预期值。因此#set操作似乎是正确的

我假设它将引用后面的点错误地作为函数调用。 如何在Velocity模板语言中转义点?

您可以使用它来标记变量的开始和结束:

"url": "https://${apiid}.execute-api.${region}.amazonaws.com/$stage/$path"
如果需要显式地将Velocity指令与周围的文本分开,可以用大括号({和})将其括起来:


那太好了!谢谢你的快速回复。