servlet入门问题,超级简单!
下面是一段最简单的servlet结构,俺是刚刚接触,怎么具体内容要写在异常里呀?
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class ServletTemplate extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws
ServletException,
IOException {
// Use "request " to read incoming HTTP headers
// (e.g., cookies) and query data from HTML forms.
// Use "response " to specify the HTTP response status
// code and headers (e.g., the content type, cookies).
PrintWriter out = response.getWriter();
// Use "out " to send content to browser.
}
}
------解决方案--------------------楼主什么意思?
------解决方案--------------------throws ServletException, IOException 并不代码是写在异常里。
而是表示doGet方法有可能会抛出ServletException、IOException 2种异常