velocity模板页
模板页:dafault.vm
<html> <body> it's a default page. <div style="border:solid 5px black;padding:20px;"> $screen_content </div> </body> </html>
配置文件:velocity.properties
input.encoding=UTF-8 output.encoding=UTF-8 resource.loader = webapp webapp.resource.loader.class = org.apache.velocity.tools.view.servlet.WebappLoader tools.view.servlet.layout.default.template = default.vm tools.view.servlet.error.template = error.vm tools.view.servlet.layout.directory = /layout/ webapp.resource.loader.path=/WEB-INF/templates/ webapp.resource.loader.path=/ webapp.resource.loader.path=/WEB-INF/vm/
还有web.xml
<servlet> <servlet-name>velocityView</servlet-name> <servlet-class>org.apache.velocity.tools.view.VelocityLayoutServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>velocityView</servlet-name> <url-pattern>*.vm</url-pattern> </servlet-mapping>
调用模板显示页面:index.vm
#set($hello="Velocity") <b> Welcome to $hello World11 ! </b>
如果我们不能延长生命的长度,我们可以拓宽它的广度!