Velocity is a Java-based template engine, which allows anyone to simply use the template language to reference CodeDefined Object. As a relatively complete template engine, velocity has powerful functions, but it also increases application complexity. The basic syntax of the simple velocity script is as follows: 1. "#" is the script statement used to identify the velocity, including # Set, # If, # else, # End, # foreach, # End, # iinclude, # parse, # macro, etc;
For example:
# If ($ info. IMGs)
# Else
# End
2. "$" is used to identify an object (or as a variable );
For example, $ I, $ MSG, $ tagutil. Options (...), etc.
3. "{}" is used to clearly identify the velocity variable;
For example, there is a $ someonename in the page. In this case, velocity uses someonename as the variable name. ProgramTo display the name character next to the someone variable, the above label should be changed to $ {someone} Name.
4 ,"! "Is used to forcibly display non-existent variables as blank.
For example, if the page contains $ MSG, the value of MSG is displayed if the MSG object has a value. If the MSG object does not exist, the $ MSG character is displayed on the page. This is not expected. In order to display a non-existent variable or an object whose value is null as a blank space, you only need to add a "!" before the variable name. .
Example: $! MSG