##velocity最简环境搭建 直接来步骤了:html
到官网下载安装包(目前最新包连接以下)web
velocity-1.7.zipapache
在Eclipse里面建立动态web工程url
要添加的jar包有两部分,将如下内容拷贝到新工程的WebContent\WEB-INF\libcode
在WebContent目录下添加 index.vm,内容以下:xml
#set($hello="Velocity") <html> <head> <title>Hello</title> </head> <body> Hello $hello World ! </body> </html>
修改web.xmlhtm
<servlet> <servlet-name>velocityView</servlet-name> <servlet-class>org.apache.velocity.tools.view.servlet.VelocityViewServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>velocityView</servlet-name> <url-pattern>*.vm</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.vm</welcome-file> </welcome-file-list>
运行程序,能看到ip
说明运行成功ci
注意:
添加velocity-tools-2.0.zip 包里面 lib下全部jar包而不是velocity-1.7.zip包lib下的全部jar包
在WebContent目录下添加 index.vm,层级有时候容易看错,好比你加到WEB-INF文件夹下的话,就会一直报错说找不到index。
搭建环境的时候tool.xml暂时是不须要的,须要的时候再往里面添加,这里是最简环境