当前位置: 技术问答>java相关
请大家帮我看看这个问题啦!
来源: 互联网 发布时间:2015-05-30
本文导语: javac一个HelloWorld.java,代码如下 import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class HelloWorld extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException...
javac一个HelloWorld.java,代码如下
import java.io.*;
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("");
out.println("");
out.println("");
out.println("Hello World!");
out.println("");
out.println("");
out.println("Hello World!");
out.println("");
out.println("");
}
}
但提示javax.servlet,javax.servlet.http包不存在!!
而tomcat里servlet的例子是运行正常的
请问是什么问题啊?
import java.io.*;
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("");
out.println("");
out.println("");
out.println("Hello World!");
out.println("");
out.println("");
out.println("Hello World!");
out.println("");
out.println("");
}
}
但提示javax.servlet,javax.servlet.http包不存在!!
而tomcat里servlet的例子是运行正常的
请问是什么问题啊?
|
看看你的classpath里有没有那个包,就是servlet.jar可以放在环境变量的classapth,也可以在命令行写set classpath=%classpath%;pathservlet.jar
tomcat可以运行是因为tomcat运启动时会设置环境变量
tomcat可以运行是因为tomcat运启动时会设置环境变量