servlet编译问题
下面是我的Test.java
package test;
import
java.io.IOException;
import java.io.PrintWriter;
import
javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Test extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws
ServletException,
IOException {
PrintWriter out=response.getWriter();
out.println( " <html> <body> <h1> This is a servlet test. </h1> </body> </html> ");
out.flush();
}
}
为什么在dos下老报错:找不到javax.servlet这个软件包
------解决方案--------------------你把servlet-api.jar加到classpath环境变量里就可以了,如果用的Tomcat,servlet-api.jar在Tomcat安装目录下的common\lib里.