Similar to freemarker. Nice stuff.
1 Configuration
Put the toolbox. xml of velocity under Web-INF, And put velocity. properties under Web-INF.
2 integration with spring
<Servlet>
<Servlet-Name> velocity </servlet-Name>
<Servlet-class>
Org. Apache. Velocity. Tools. View. servlet. velocityviewservlet
</Servlet-class>
<Init-param>
<Param-Name> org. Apache. Velocity. toolbox </param-Name>
<Param-value>/WEB-INF/toolbox. xml </param-value>
</Init-param>
<Init-param>
<Param-Name> org. Apache. Velocity. properties </param-Name>
<Param-value>/WEB-INF/velocity. properties </param-value>
</Init-param>
<Load-on-startup> 10 </load-on-startup>
</Servlet>
<! -- Map *. VM files to velocity -->
<Servlet-mapping>
<Servlet-Name> velocity </servlet-Name>
<URL-pattern> *. VM </url-pattern>
</Servlet-mapping>
3. Common usage
# If ($ userinfo. haspermission (1 ))
....
# End
<Input type = "text" name = "rolename" maxlength = "15" value = "$! Role. getrolename () "class =" inputstyle "disabled>
# Foreach ($ FJ in $ fjlist)
<Tr Height = 25>
<TD align = left> & nbsp; <a href = "... $! FJ. getpath () $! FJ. getsite ()/$! FJ. getfilename () "target =" rithtframe ">$! FJ. gettitle () </a> </TD>
</Tr>
# End
# Set ($ I = 1)
# Foreach ($ role in $ page. getlist ())
<TD> $! I </TD>
....
# Set ($ I = $ I + 1)
# End