Velocity 11th application examples --- the sample code for null processing is output as is if no processing is performed.
$ Title
This is not what we expect
We want to output an empty string. we should do this: $! Title
// 2 Create a Context objectVelocityContextcontext = new VelocityContext (); // 3 Addyou data object to this contextcontext. put ("title", null); // 4 Choose a templateTemplatetemplate = Velocity. getTemplate ("null. vm "); // 5 Merge the template and you data to produce the outputStringWritersw = new StringWriter (); BufferedWriterbufferWriter = new BufferedWriter (sw); template. merge (context, bufferWriter); bufferWr Iter. flush (); System. out. println (sw. toString (); null. vm $ title =====$! Title
The above is the content processed by null in velocity's 11th application example. For more information, see PHP's Chinese website (www.php1.cn )!