我正在尝试使用 servlet 制作一个简单的应用程序,在该应用程序中我从用户那里检索数据,例如姓名、姓氏、年龄和电话号码,然后在插入后将其存储在数据库中,但我在执行此操作时遇到了困难,因为在编译和使用 ant 进行部署我没有收到任何错误,但是在单击表单中的提交按钮后,我收到了一个错误。我不知道问题的原因是什么。在编译和部署之前,我的 lib 文件夹中都有我的 servlet 和数据库 jar 文件,但在部署后只有一个 jar 文件被正确部署。非常感谢任何启示。先感谢您。我在想也许应该修改我的 build.xml 以便我的两个 jars 文件都可以正确部署。我收到以下错误。
我已经包含了我的 build.xml 文件。
指导系统 201103
<property name="name" value="servlet"/>
<property name="project.code" value="servlet"/>
<property name="project.name" value="servlet"/>
<property name="version" value="1.00.00"/>
<!--*** Source properties ***-->
<property name="src" location="src"/>
<property name="src-main" location="${src}/main"/>
<property name="src-main.java" location="${src-main}/java"/>
<property name="src-main.resources" location="${src-main}/resources"/>
<property name="src-main.webapp" location="${src-main}/webapp"/>
<property name="src-test" location="${src}/test"/>
<property name="src-test.java" location="${src-test}/java"/>
<property name="src-test.resources" location="${src-test}/resources"/>
<property name="lib" location="lib"/>
<!--*** Target properties ***-->
<property name="target" location="target"/>
<property name="build" location="${target}/build"/>
<property name="build.classes" location="${build}/classes"/>
<property name="deploy" location="${target}/deploy"/>
<property name="ide" location="${target}/ide"/>
<!--*** Tomcat Properties ***-->
<property name="tomcat-webapps" location="C:\apache-tomcat-7.0.37-windows-x64\apache-tomcat-7.0.37\webapps"/>
<!--*** Deploy properties ***-->
<property name="tomcat.deploy.dir" location="${tomcat-webapps}"/>
<!--*** Classpath settings ***-->
<path id="classpath">
<fileset dir="${lib}">
<include name="**/*.jar"/>
</fileset>
<pathelement path="${build}/classes"/>
</path>
<!--***************************************************************************************************************
* Target: Help (Default)
***************************************************************************************************************-->
<target name="help" description="Gives help on all tasks in this build file">
<echo>Run "ant -projecthelp" or "ant -p" for a list of valid targets for this ant buildfile."</echo>
</target>
<!--***************************************************************************************************************
* Target: createTempDirs
***************************************************************************************************************-->
<target name="init:create-temp-dirs" description="Creates all relevant temporary directoriees. Typically only used the first time these directories need to be created.">
<mkdir dir="${target}"/>
<mkdir dir="${build}"/>
<mkdir dir="${build.classes}"/>
<mkdir dir="${deploy}"/>
<mkdir dir="${ide}"/>
<mkdir dir="${ide}/classes"/>
</target>
<!--***************************************************************************************************************
* Target: Clean
***************************************************************************************************************-->
<target name="clean" description="Deletes all relevant files and directories eg. build classes, build directories.">
<!-- Kill the build directory -->
<delete dir="${build}" />
<!-- Delete backup files, if necessary -->
<!-- Delete all temporary files, if necessary -->
</target>
<!--***************************************************************************************************************
* Target: prepare
***************************************************************************************************************-->
<target name="prepare" depends="init:create-temp-dirs" description="Creates all relevant dirs, expand jars, etc.">
<mkdir dir="${build}"/>
<mkdir dir="${build.classes}"/>
</target>
<!--***************************************************************************************************************
* Target: java
***************************************************************************************************************-->
<target name="_compile" depends="prepare" >
<javac srcdir="${src-main.java}" destdir="${build.classes}">
<classpath refid="classpath"/>
<include name="**/*.java"/>
</javac>
<!-- copy all relevant confirguration files -->
<copy todir="${build.classes}/resources">
<fileset dir="${src-main}/resources"/>
</copy>
<!-- copy all file in root java directory. -->
<copy todir="${build.classes}">
<fileset dir="${src-main.java}" includes="*.*"/>
</copy>
</target>
<target name="compile" depends="clean, _compile"
description="Does a clean Java compile ie. all previous built classes are first deleted and then a full recompile takes place." />
<target name="compile:fast" depends="_compile"
description="Does a Java compile only on changed files. Previously compiled files are left untouched." />
<!--***************************************************************************************************************
* Target: war related
***************************************************************************************************************-->
<property name="deploy.warfile.name" value="${deploy}/${project.name}.war"/>
<!-- Do a WAR build from the given build directory. No Hibernate build is done. -->
<target name="war:build" description="Creates the War file for this project.">
<!--<delete file="${deploy.warfile.name}" />-->
<war destfile="${deploy.warfile.name}" webxml="${src-main.webapp}/WEB-INF/web.xml">
<classes dir="${build.classes}" />
<webinf dir="${src-main.webapp}/WEB-INF" />
<fileset dir="${src-main.webapp}" excludes="WEB-INF/**/*.*" />
<lib dir="${lib}" includes="**/*.jar" excludes="servlet*.jar, jsp*.jar, javax*.jar" />
</war>
</target>
<!-- Do a WAR Build and Deploy To Tomcat -->
<target name="war:deploy" depends="war:build" description="Builds the war file (war:build) and deploys it to Tomcat.">
<copy file="${deploy.warfile.name}" todir="${tomcat.deploy.dir}" />
</target>