vtl

AWS API Gateway - How do I get the date/timestamp/epoch in a body mapping template?

故事扮演 提交于 2019-12-04 10:50:20
I need to include the request time in the body mapping template for an API Gateway method. Is there a date/time variable or function? I couldn't find anything in the template reference . Example body mapping template: Action=SendMessage&MessageBody=$util.urlEncode("{""timestamp"":""TIMESTAMP_HERE"",""body-json"":$input.json('$'),""params"":""$input.params()""}") UPDATE: API Gateway just added two new context variables http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html $context.requestTime The CLF-formatted request time (dd/MMM/yyyy:HH:mm:ss

IntelliJ IDEA override $user

痴心易碎 提交于 2019-12-03 15:01:02
It's a quite simple question, but I can't find an answer to it using SO-Search and Google. Is it possible to override the default $user VTL-variable used in file-templates globally, instead of setting it in each template with #set($user = "...") ? Like some sort of setup-script for IntelliJ itself, where I can alter the value? Thanks in advance. By the way, I'm using IntelliJ Ultimate 12.1.6. Pr0gr4mm3r You want to modify the IntelliJ's .vmoptions file(s) in a text editor. In Windows, edit IntelliJ-Install-Location/bin/idea.exe.vmoptions and/or IntelliJ-Install-Location/bin/idea64.exe

Replace a Substring of a String in Velocity Template Language

巧了我就是萌 提交于 2019-12-03 10:34:20
问题 I want to replace a part of a string in Velocity Template Language with another string. For Example: #set($a = "Hello") #set($b = "+") I want to replace ll in Hello with ++. The output should be He++o Please help me Thanks Kishore 回答1: By default you can use the methods of the Java String object: #set( $a = "Hello" ) #set( $b = $a.replace("l", "+") ) ${b} will produce He++o and you can also use velocity variables as arguments to your method calls, e.g.: #set( $a = "Hello" ) #set( $b = "+" )

How to access an object's public fields from a Velocity template

橙三吉。 提交于 2019-11-29 13:25:43
Here is my object class: public class Address { public final String line1; public final String town; public final String postcode; public Address(final String line1, final String town, final String postcode) { this.line1 = line1; this.town = town; this.postcode = postcode; } } I add it to the velocity context like this: Address theAddress = new Address("123 Fake St", "Springfield", "SP123"); context.put("TheAddress", theAddress); However, when writing the template, the following will not render the address fields (however, it works fine when I add getters to the Address class) <Address> <Line1

Create and iterate through an array in Velocity Template Language

烂漫一生 提交于 2019-11-28 22:31:57
How to create an array in VTL and add contents to the array? Also how to retrieve the contents of the array by index? According to Apache Velocity User Guide , right hand side of assignments can be of type Variable reference List item String literal Property reference Method reference Number literal ArrayList Map You can create an empty list, which would satisfy all your needs for an array, in an Apache Velocity template with an expression like: #set($foo = []) or initialize values: #set($foo = [42, "a string", 21, $myVar]) then, add elements using the Java add method: $foo.add(53); $foo.add(

How to access an object's public fields from a Velocity template

早过忘川 提交于 2019-11-28 07:21:19
问题 Here is my object class: public class Address { public final String line1; public final String town; public final String postcode; public Address(final String line1, final String town, final String postcode) { this.line1 = line1; this.town = town; this.postcode = postcode; } } I add it to the velocity context like this: Address theAddress = new Address("123 Fake St", "Springfield", "SP123"); context.put("TheAddress", theAddress); However, when writing the template, the following will not