当前位置: 代码迷 >> J2EE >> cannot be cast to javax.servlet.Servlet解决思路
  详细解决方案

cannot be cast to javax.servlet.Servlet解决思路

热度:95   发布时间:2016-04-22 00:59:03.0
cannot be cast to javax.servlet.Servlet
刚开始学习,写了一个简单的servlet:
问题是:在Jcreator上编译通过,但是发布以后浏览器中出现
root cause 

java.lang.ClassCastException: com.tsinghua.Hello cannot be cast to javax.servlet.Servlet
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
java.lang.Thread.run(Thread.java:619)


请问问题何在啊?
public class Hello{

public void init(ServletConfig parm1) throws ServletException {
// TODO: Add your code here
System.out.println("init it");

}


public ServletConfig getServletConfig() {
// TODO: Add your code here
return null;
}


 
public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
// TODO: Add your code here
System.out.println("sdfjsdf");
PrintWriter pw = res.getWriter();
pw.println("helle");


}


public String getServletInfo() {
// TODO: Add your code here
return "";
}


public void destroy() {
// TODO: Add your code here
System.out.println("destroy");

}

}

------解决方案--------------------
public class Hello exterds HttpServlet{
  相关解决方案