当前位置: 代码迷 >> Java Web开发 >> 求救!Servlet运行出错!Wrapper cannot find servlet class 小弟我快疯了
  详细解决方案

求救!Servlet运行出错!Wrapper cannot find servlet class 小弟我快疯了

热度:177   发布时间:2016-04-17 12:49:19.0
求救!Servlet运行出错!Wrapper cannot find servlet class 我快疯了
编写了一个简单的Servlet,HelloWorld.java
package   test;

import   java.io.*;
import   java.text.*;
import   java.util.*;
import   javax.servlet.*;
import   javax.servlet.http.*;

public   class   HelloWorld   extends   HttpServlet
{
public   void   doGet(HttpServletRequest   request,HttpServletResponse   response)
throws   IOException,ServletException
{
response.setContentType( "text/html ");
PrintWriter   out   =   response.getWriter(); out.println( " <html> ");
out.println( " <head> ");
                  out.println( " <title> HelloWorld </title> ");
out.println( " </head> ")
out.println( " <body> HelloWorld </body> ");
out.println( " </html> ");
}
}
环境变量
JAVA_HOME=C:\j2sdk1.4.2_13
CATALINA_HOME=C:\Program   Files\Apache   Software   Foundation\Tomcat   5.0
CLASSPATH=C:\j2sdk1.4.2_13\lib\dt.jar;C:\j2sdk1.4.2_13\lib\tool.jar;C:\j2sdk1.4.2_13\lib\tools.jar;C:\Program   Files\Apache   Software   Foundation\Tomcat   5.0\common\lib\servlet-api.jar;C:\Program   Files\Apache   Software   Foundation\Tomcat   5.0\common\lib\jsp-api.jar

Path=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\j2sdk1.4.2_13\bin

将编译完后的HelloWorld.class放入%CATLINA_HOME%\webapps\servlet\WEB-INF\classses\test\目录下
并且修改了servlet\WEB-INF\下的web.xml
<?xml   version= "1.0 "   encoding= "ISO-8859-1 "?>

<!DOCTYPE   web-app
        PUBLIC   "-//Sun   Microsystems,   Inc.//DTD   Web   Application   2.3//EN "
        "http://java.sun.com/dtd/web-app_2_3.dtd ">

<web-app>
    <display-name> my   program </display-name>
    <description>
          test
    </description>
   
    <servlet>
    <servlet-name> HelloWorld </servlet-name>
    <display-name> HelloWorld </display-name>
    <description> A   test   Servlet </description>
    <servlet-class> test.HelloWorld </servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name> HelloWorld </servlet-name>
    <url-pattern> /HelloWorld </url-pattern>
    </servlet-mapping>
</web-app>
重新启动Tomcat,但是在浏览器中输入http://127.0.0.1:8080/webapps/servlet/HelloWorld
出现下面的错误
type   Exception   report

message  

description   The   server   encountered   an   internal   error   ()   that   prevented   it   from   fulfilling   this   request.

exception  

javax.servlet.ServletException:   Wrapper   cannot   find   servlet   class   test.HelloWorld   or   a   class   it   depends   on
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
  相关解决方案