编译servlet程序中的错误

时间:2013-10-23 20:00:32

标签: java servlets tomcat7

在尝试编译程序时,我在servlet类中遇到编译错误。

代码:

import javax.servlet.*;   
import java.io.*;  
public class Servlet1 extends GenericServlet  
{   
     pubilc void service(ServletRequest req,ServletResponse res)throws ServletException,IOException  
 {  
  PrintWriter out= res.getWriter();   
  out.println("<html>");  
  out.println("<body bgcolor=pink>");  
  out.println("<h1> hello client <h1>");  
  out.println("</body>");  
  out.println("</html>");`  
 }  
}

错误:

<identifier> excepted  
     public void service (ServletRequereq, ServletRespons res) throws ServletException,IOException
invalid method declaration; return type required 
    public void service(ServletRequereq, ServletResponse res)throws ServletException,IOException 

1 个答案:

答案 0 :(得分:3)

小错字:pubilc应为public