VelocityEngine 和Velocity类解析
在我们 普通使用 velocity 的过程中,或者一开始使用 velocity 做 demo 的同学,总会对这段代码有印象: VelocityEngine velocity = new VelocityEngine (); VelocityContext context = new VelocityContext (); context . put ( "name" , "czy" ); Template template = velocity . getTemplate ( "/src/main/resources/test.vm" ); BufferedWriter writer = new BufferedWriter ( new OutputStreamWriter ( System . out )); template . merge ( context , writer ); writer . flush (); writer . close (); 但是阅读源码会发现在 org.apache.velocity.app包下,会有velocoty和velocityEngine这两个类,里面的方法大同小异,都是init 加setproperty这里设置属性的方法,然后将 VelocityEngine velocity = new VelocityEngine ();