我在哪里可以找到javax ?编译Servlet所需的Servlet类



我在这个问题上花了很多时间,我需要javax.servlet。Servlet(也包括javax.persistence)可用。我下载了它,并把它放在所有我认为有意义的地方(C:Program FilesJavajdk1.6.0_20lib…)C:SunSDKlib [Glassfish目录])。我一直在这个问题上出错。如有任何提示或提示,不胜感激。

下面是我运行"ant"时得到的错误:

    [javac]     public void service(HttpServletRequest request, HttpServletRespo
nse response) throws ServletException, IOException;
    [javac]                         ^
    [javac] C:petstore~svntrunkwsappspetstoresrcjavacomsunjavaeebluep
rintspetstorecontrollerControllerAction.java:16: cannot find symbol
    [javac] symbol  : class HttpServletResponse
    [javac] location: interface com.sun.javaee.blueprints.petstore.controller.Co
ntrollerAction
    [javac]     public void service(HttpServletRequest request, HttpServletRespo
nse response) throws ServletException, IOException;
    [javac]                                                     ^
    [javac] C:petstore~svntrunkwsappspetstoresrcjavacomsunjavaeebluep
rintspetstorecontrollerControllerAction.java:16: cannot find symbol
    [javac] symbol  : class ServletException
    [javac] location: interface com.sun.javaee.blueprints.petstore.controller.Co
ntrollerAction
    [javac]     public void service(HttpServletRequest request, HttpServletRespo
nse response) throws ServletException, IOException;
    [javac]
                     ^
    [javac] C:petstore~svntrunkwsappspetstoresrcjavacomsunjavaeebluep
rintspetstorecontrollerControllerServlet.java:16: package javax.servlet does
not exist
    [javac] import javax.servlet.ServletConfig;
    [javac]                     ^
    [javac] 100 errors
BUILD FAILED
C:petstore~svntrunkwsbp-projectcommand-line-ant-tasks.xml:80: Compile faile
d; see the compiler error output for details.
Total time: 2 seconds

下面是command-line-ant-tasks.xml的一部分:

<dirname property="antfile.dir" file="${ant.file}"/>
<path id="classpath">
    <fileset dir="${javaee.home}" includes="lib/javaee.jar, lib/appserv-rt.jar, lib/appserv-ws.jar"/>
    <pathelement location="${build.classes.dir}"/>
    <pathelement path="${javac.classpath}"/>
    <pathelement path="${extra.classpath}"/>
    <path refid="javaee.classpath" />
</path>
<!-- the includeantruntime was added 8/31 -cp="C:servlet"  -->
<target name="bpp-actual-compilation" if="has-java-sources">
    <echo>Compiling ${module.name}</echo>
    <mkdir dir="${build.classes.dir}"/>
    <javac srcdir="${src.dir}"
        source="${default.javac.source}"
        target="${default.javac.target}"
        excludes="${javac.excludes}"
        debug="${javac.debug}"
        debuglevel="${javac.debuglevel}"
        destdir="${build.classes.dir}"
        includeantruntime="false"
        includes="**">
        <classpath refid="classpath"/>
    </javac>
</target>

我认为这是build.xml的相关部分:

<target name="insert-proxy-settings">
    <copy todir="${build.web.dir}/WEB-INF/" file="web/WEB-INF/web.xml"/>
    <concat destfile="${build.dir}/proxy.properties">proxy.host=${proxy.host}
        proxy.port=${proxy.port}
        <filterchain>
            <expandproperties/>
        </filterchain>
    </concat>
    <!-- Replace value of the proxy settings in web.xml for Google maps -->
    <replace file="${build.web.dir}/WEB-INF/web.xml" propertyFile="${build.dir}/proxy.properties">          
        <replacefilter token="@@proxy.host@@" property="proxy.host"/>
        <replacefilter token="@@proxy.port@@" property="proxy.port"/>
    </replace>        
</target>
<target name="unzipIndexes">
    <unzip src="lib/petstoreIndexes.zip" dest="${javaee.domaindir}/lib/petstore" overwrite="true"/>
</target>
<target name="setup" depends="init, create-bp-ui-5-jar">
    <mkdir dir="${javaee.domaindir}/lib/petstore/images"/>
    <ant dir="." antfile="setup/setup.xml" target="setup" inheritAll="false" inheritRefs="false"/>
    <antcall target="unzipIndexes"/>
</target>

我认为这是xml的相关部分

我假设您下载了一个servlet-xx.jar或类似的文件,另一个用于持久化类。这些应该放在ant构建脚本中类路径所引用的lib目录中。然后需要将它们添加到上面的ant构建脚本行中。例如,在include ="…"的行尾添加"lib/servlet-xx.jar, lib/persistence.jar"。价值。

将下载的jar文件的实际名称替换为我在上面使用的文件名。

相关内容

  • 没有找到相关文章

最新更新