在命令提示符下进到先前创制的hello目录下,执行 jar cvf hello.war * ,我们便得到hello.war。将它拷贝至webapps目录下,ok,来看最后一步,打开tomcat的目录conf中的server.xml,加入:
| <Context path="/hello" docBase="hello.war" debug="0" reloadable="true"/> |
大功告成!运行它,启动tomcat,后在浏览器中输入http://localhost:8080/hello/HelloWorld,有了吗? 最后,如果你想用ant来完成以上的打包活动,下面就告诉你: 对于jar来说。在build.xml中,
| <target name="jar"> <jar destfile="${app_home}/hello.jar"> <fileset dir="${dest}" includes="**"/> <!--fileset dir="${dest}" includes="**/action.properties"/--> </jar> </target>
| 对于war,
| <war warfile="hello.war" webxml="./WEB-INF/web.xml"> <fileset dir="html"/> <lib dir="lib/"> <exclude name="oracle*.jar"/> </lib> <classes dir="build/servlets"> <include name="**/*.class"/> </classes> </war>
| 好了,就这么多,希望对你有点帮助。:) 补充: jar基本操作: 1. 创建jar文件
| jar cf jar-file input-file(s) c---want to Create a JAR file. f---want the output to go to a file rather than to stdout. eg: 1)jar cf myjar.jar query_maintain_insert.htm 2)jar cvf myjar.jar query_maintain_insert.htm v---Produces verbose(详细的) output. |
|