你的访问地址可能不对。
这样吧,你在webapps建一个自己的比如myapp的目录,然后在其下建classes和WEB-INF目录,class拷到classes里,在web-inf里拷一个web.xml改成自己的配置
<servlet>  
       <servlet-name>helloworld</servlet-name>  
       <servlet-class>helloworld</servlet-class>  
   </servlet>  
<servlet-mapping>  
       <servlet-name>helloworld</servlet-name>  
       <url-pattern>/helloworld</url-pattern>  
   </servlet-mapping> 然后在配置myapp这个虚拟目录,运行http://localhost:8080/myapp/HelloWorld

解决方案 »

  1.   

    to: kreven 
       谢谢你的回答,我马上试一下~
      

  2.   

    修改web-inf/web.xml文件,加入
    <servlet-mapping>
            <servlet-name>invoker</servlet-name>
            <url-pattern>/servlet/*</url-pattern>
        </servlet-mapping>访问servlet方法
    http://localhost:8080/你的虚拟目录/servlet/servlet包.名
      

  3.   

    <servlet>  
           <servlet-name>helloworld</servlet-name>  
           <servlet-class>HelloWorld</servlet-class>  <!--类名-->
       </servlet>  
    <servlet-mapping>  
           <servlet-name>helloworld</servlet-name>  
           <url-pattern>/helloworld</url-pattern>  
       </servlet-mapping>  
      <!-- The mapping for the invoker servlet -->
      <servlet-mapping>
        <servlet-name>invoker</servlet-name>
        <url-pattern>/servlet/*</url-pattern>
      </servlet-mapping>
    然后在ie的地址栏输入http://localhost:8080/helloworld  "servlet-name"
      

  4.   

    还是不行,能发一个例程给我吗
    [email protected]
    谢谢~
      

  5.   

    http://localhost:8080/examples/helloworld
      

  6.   

    你的Servlet发布在webapps/examples目录下。http://localhost:8080/examples/helloworld
    还有要区分大小写
      

  7.   

    http://localhost:8080/examples/helloworld区分大小写
      

  8.   

    http://localhost:8080/helloworld,后面的helloworld应该和你的<Servlet-name>标签的内容一致吧。另外,不需要在URL中包含examples,也可以用http://localhost:8080/servlet/helloworld也应该行的。