I didn't plan to learn about the velocity template engine. I simply learned how to use velocity in solr browse.
Download the velocity-tools-2.0.zip file from http://velocity.apache.org/download.cgiand then decompress it. The decompressed velocity-tools-2.0 \ examples directory contains three war files. Select simple. war and put it in the webapps directory of tomcat, and then start tomcat.
Enter http: // localhost: 8983/simple/in the browser to see the effect of index. vm.
What should we do if we develop it on our own?
Create a web project according to the structure in the simple directory in webapps. Showcase. war contains many velocity tools and usage methods.
If you directly copy the web. xml in the simple project, an error may be reported: Can not find the tag library descriptor for "http://velocity.apache.org/velocity-view"
In web. xml
- <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
-
- <web-app>
Change
- <web-app version="2.5"
- xmlns="http://java.sun.com/xml/ns/javaee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
- http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
No error will be reported.
This article from the "every day progress a little" blog, please be sure to keep this source http://sbp810050504.blog.51cto.com/2799422/1183931