当前位置: 技术问答>java相关
在线等待:tomcat 运行一个简单的HelloWorldServlet.class出错?(那位大哥指点一下,我都调试了2个晚上了)
来源: 互联网 发布时间:2015-03-31
本文导语: | 我的程序是这样的: import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class HelloWorldExample extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletRes...
|
我的程序是这样的:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorldExample extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("");
out.println("");
out.println("" +"Hello World!"+ "");
out.println("");
out.println("");
}
}
存入到C:tomcatwebappsexamplesWEB-INFclasses下进行javac编译
在autoexe.bat中没有加tomcat的classpath,启动tomcat后键入:
http://127.0.0.1:8080/examples/servlet/HelloWorldExample一切ok!
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorldExample extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("");
out.println("");
out.println("" +"Hello World!"+ "");
out.println("");
out.println("");
}
}
存入到C:tomcatwebappsexamplesWEB-INFclasses下进行javac编译
在autoexe.bat中没有加tomcat的classpath,启动tomcat后键入:
http://127.0.0.1:8080/examples/servlet/HelloWorldExample一切ok!
|
是不是CLASSPATH没设置好啊!?
|
把tomcat中的servlet.jar文件加到用户的classpath 中即可
|
不要用jbuild的tomcat,自己去www.apache.org下一个tomcat4.0独立安装保证成功
|
共同学习