日期:2014-05-20  浏览次数:20910 次

eclipse开发servlet问题
我用的eclipse是j2ee版的
装了myeclipse6
在写一个简单的servlet文件时
import   java.io.*;
import   javax.servlet.*;//这些都被告知不能解析,请问该怎么弄?
import   javax.servlet.http.*;//

public   class   HelloWorld   extends   HttpServlet   {
public   void   doGet(HttpServletRequest   request,   HttpServletResponse   response)
throws   ServletException,   IOException   {

response.setContentType( "text/html ");
PrintWriter   out   =   response.getWriter();
out.println( " <html> <head> <title> ");
out.println( "This   is   my   first   Servlet ");
out.println( " </title> </head> <body> ");
out.println( " <h1> Hello,World! </h1> ");
out.println( " </body> </html> ");

}
}

------解决方案--------------------
构建路径里面没有加相应的包,用MYECLIPSE首先要建立J2EE工程才会自动导入相应的J2EE包
------解决方案--------------------
把tomcat/common/lib/servlet-api.jar倒进来就行了!