我安装了tomcat,其它测试都通过了,可就是测试servlet是怎么也不成功,郁闷啊!!!
我把已经编译好的.class文件放在了E:\Tomcat\Tomcat 6.0\webapps\ROOT\WEB-INF\classes目录下,在浏览器输入http://lihaifeng:8080/servlet/HelloWorld1就是通过不了,还有就是那个web.xml里边我也注释了,出现错误为:

HTTP Status 404 - /servlet/HelloWorld1.class--------------------------------------------------------------------------------type Status reportmessage /servlet/HelloWorld1.classdescription The requested resource (/servlet/HelloWorld1.class) is not available.
--------------------------------------------------------------------------------Apache Tomcat/6.0.14
烦死了,恳求朋友没帮帮忙啊!!!

解决方案 »

  1.   

    你怎么自己放class文件 那个是自动生成的  web。xml贴出来 
      

  2.   

    不是说这个WEB-INF目录下没有classes文件就自己建立个。然后把编译的.class文件放到class目录里吗?
    我的WEB-INF目录下只有个web.xml文件,内容为:<?xml version="1.0" encoding="ISO-8859-1"?>
    <!--
     Licensed to the Apache Software Foundation (ASF) under one or more
      contributor license agreements.  See the NOTICE file distributed with
      this work for additional information regarding copyright ownership.
      The ASF licenses this file to You under the Apache License, Version 2.0
      (the "License"); you may not use this file except in compliance with
      the License.  You may obtain a copy of the License at      http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software
      distributed under the License is distributed on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      See the License for the specific language governing permissions and
      limitations under the License.
    --><web-app xmlns="http://java.sun.com/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
       version="2.5">  <display-name>Welcome to Tomcat</display-name>
      <description>
         Welcome to Tomcat
      </description>
    </web-app>还有Tomcat 6.0\conf里面的web.xml里的需要注释的内容也注释了!
    就是不行,朋友帮帮忙啊!!!
      

  3.   

    你的Java类是不是带了一个包"servlet"?
    如果这样的话,你还要在classes下面再建一个文件夹“servlet”,然后再把class文件放进去还有,你的web.xml文件里要加上servlet定义和映射
      

  4.   

    servlet是要在web.xml文件中注册的
    <servlet>
        <servlet-name>hello</servlet-name>
        <servlet-class>HelloWorld1.class</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>hello</servlet-name>
        <url-pattern>/hello</url-pattern>
    </servlet-mapping>在浏览器里面输入http://lihaifeng:8080/hello应该就ok了,而且你的url是通过/serlvet这种方式来访问的,
    不是很好,一般这种方式都会被禁止掉,应该是首先通过路径匹配找到对应的servlet-name然后根据name找到他所对应的类,并执行
      

  5.   

    不是开启servlet调试器。把conf文件夹下的web.xml文件.把其中如下的servlet和servlet-mapping元素注释去掉:
      
      <servlet>
      <servlet-name>invoker</servlet-name>
      <servlet-class>
      org.apache.catalina.servlets.InvokerServlet
      </servlet-class>
      ...
      </servlet>
      ...
      <servlet-mapping>
      <servlet-name>invoker</servlet-name>
      <url-pattern>/servlet/*</url-pattern>
      </servlet-mapping>
      
    就行了!可以不把web.xml文件里加servlet定义和映射!我把classes里面建立了一个servlet文件加,然后把class放进去,还是不行!!急!!!
    我在浏览器输入的是http://lihaifeng:8080/servlet/HelloWorld1
    我的从class位置为:E:\Tomcat\Tomcat 6.0\webapps\ROOT\WEB-INF\classes\servlet里面到底是什么问题啊??????
      

  6.   

    对于tomcat 5.5.x来说,修改
    <servlet>
            <servlet-name>invoker</servlet-name>
            <servlet-class>
              org.apache.catalina.servlets.InvokerServlet
            </servlet-class>
            <init-param>
                <param-name>debug</param-name>
                <param-value>0</param-value>
            </init-param>
            <load-on-startup>2</load-on-startup>
        </servlet><!-- The mapping for the invoker servlet -->
        <servlet-mapping>
            <servlet-name>invoker</servlet-name>
            <url-pattern>/servlet/*</url-pattern>
        </servlet-mapping>
        <!-- The mapping for the JSP servlet -->
    这两个地方就够了,但是对于tomcat 6来说,还要修改 
    TOMCAT_HOME/conf/context.xml文件:
    <Context reloadable="true" privileged="true">修改后的文件如下:
    <Context  reloadable="true" privileged="true">
        <!-- Default set of monitored resources -->
        <WatchedResource>WEB-INF/web.xml</WatchedResource>
        <!-- Uncomment this to disable session persistence across Tomcat restarts -->
        <!--
        <Manager pathname="" />
        -->
        <!-- Uncomment this to enable Comet connection tacking (provides events
             on session expiration as well as webapp lifecycle) -->
        <!--
        <Valve className="org.apache.catalina.valves.CometConnectionManagerValve" />
        -->
    </Context>然后在WEB-INF下建立classes文件夹,里面放入编译后的class文件后,访问
    http://localhost:8080/servlet/HelloWorld 就可以了(假设文件class文件是HelloWorld.class)。英文好的可以看如下页面:
    http://www.easywayserver.com/tomcat-installation-configuration.htm
      

  7.   

    至于 Core Servlets and JavaServer Pages: Volume 1 2nd 里面介绍的方法,是对于更早版本来说的。