Velocity用法
2019独角兽企业重金招聘Python工程师标准>>> Velocity "#"用来标识Velocity的脚本语句,包括#set、#if 、#else、#end、#foreach、#end #if($info.imgs) xx #else xxx #end "$"用来标识一个对象(或理解为变量); $msg "{}"用来明确标识Velocity变量 "!"用来强制把不存在的变量显示为空白 $!msg #set ($i=0) #foreach($info in $list) 序号:$i #set($i=$i+1) #end 单行## XXX 多行#* xxx 双引号 与 引号 #set ($var="helo") 强制string相等 "$var"="helo" 类型先定义后使用 #set($xx= "9") #set($Integer = 0) $Integer.parseInt($xx) 条件语句 #if( $foo ) #end #if($foo) #elseif() #else #end 常用实例 #foreach($course in $courses) <option value="$course.id" #if("$!query.query_course_id"=="$!course.id") selected #end>$!course.name $!course