一、下载并解压缩cactus
下载地址为http://java.chinaitlab.com/tools/45970.html 。将cactus的lib目录下的cactus-ant-1.7.1.jar复制到ant的lib目录。
二、配置cactus
cactus的配置很简单,新建一个cactus.properties文件,并把它放在ant脚本中的cactus任务的classpath下,文件中包括如下内容
具体的做法结合ant脚本再进一步解释。cactus.sysproperties=cactus.contextURL #cactus-sample-servlet-cactified就是你的测试应用所在路径,8080是端口号 cactus.contextURL = http://localhost:8080/cactus-sample-servlet-cactified cactus.servletRedirectorName = ServletRedirector cactus.jspRedirectorName = JspRedirector cactus.filterRedirectorName = FilterRedirector
三、运行ant脚本
ant脚本主要执行以下任务
1、设定classpath
<path id="project.classpath"> <fileset dir="${lib.dir}"> <include name="*.jar"/> </fileset> <!-- cactus.properties文件就需要放在lib.dir所对应的路径中 --> <pathelement location="${lib.dir}"/> <pathelement location="${tomcat.home}/common/lib/jsp-api.jar"/> <pathelement location="${tomcat.home}/common/lib/servlet-api.jar"/> </path>