apache - java velocity vm file #set use boolean variable -
we can not use boolean variable #set when find velocity project guidelines in apache official site,but worked when use in project.
#set($isright=true) #if($isright) ##execute #end #set($isright=false) #if($isright) ##not execute #end i want know whether #set boolean variable supported velocity , way use whether legal.
in velocity, there no explicit data types , hence there no boolean variables support. since velocity has been built on java platform, if specify compatible value can give expected results in such operations "if" operation (the 1 shown in code). because in java, boolean value expected in if expression , providing can casted boolean.
if give #set($isright=true1) , above written code internally treated java engine specified string inside 'if' expression couldn't casted boolean , hence throw type cast exception(or classcastexception). happen value other 'true' or 'false' strings here can casted boolean expected inside 'if' expression.
thus not boolean type support, java implementation behind scenes makes things work.
Comments
Post a Comment