1 下载tomcat:
我选择的是http://apache.reverse.net/pub/apache/tomcat/tomcat-5/v5.5.20/bin/apache-tomcat-5.5.20.exe
你可以选择不用安装解压就可以用的。
我本来是打算用解压的。可是无法启动(这个问题我以前是通过重新启动或重装系统来解决的)。所以这次只能用这个了。
2 下载安装tomcat:不用说了吧
3 运行D:/Tomcat目录/bin/下的tomcat5或者管理的tomcat5w。自己运行就知道(包括运行和关闭)。如果你是解压的应该是bin目录下的startup.bat文件。shutdown.bat就是关闭了。
4 这时你可以允许默认的http://localhost:8080/检查是否成功安装了。出现欢迎界面没?
5 如果要设置自己的程序发行目录:
D:/Tomcat目录/conf对应的文件有个server.xml修改里面的就可以了。当然你可以放入tomcat默认的webapps目录下运行。但是这个一般不用。
<Context path="/dblog" docBase="d:/dblog" debug="0" reloadable="ture" />
</Host>
找到</Host>在前面添加上面的内容。这样你的默认web文件夹就是d:/dblog。当然你怎么放文件你先知道然后再设置的了。
6 Velocity的设置。
你必须将它的包放入对应文件夹。我的如下:
D:/dblog/WEB-INF/lib下面的2个包
velocity-1.4.rar
velocity-tools-1.2.rar
至于这2个包的用途。我就不管了。因为我不打算用这个。能让我的程序跑就行了。不过我的环境中tomcat的里面也加载了这些包。估计不用也行。你可以试一下。
7 修改你的tomcat目录/ bin/conf文件夹web.xml
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.vm</welcome-file>
</welcome-file-list>
8 编写个代码:
index.vm
#set($hello="Velocity")
<html>
<head>
<title>Hello</title>
</head>
<b>
Welcome to $hello World !
</b>
</html>
9 运行程序http://localhost:8080/dblog/index.vm即可。