谁来解释下ServletConfig这个类
最近在学习servlet相关的内容,有一个问题不明白,为什么在取ServletConfig对象的参数值的时候,还需要覆写doGet方法呢?
public class ServletConfigTest extends HttpServlet{ /** * */ private static final long serialVersionUID = 1L; private ServletConfig sc; public void init(ServletConfig config)throws ServletException{ super.init(config); this.sc = config; String s = sc.getInitParameter("hello1"); System.out.println(s); } public void doGet(HttpServletRequest req,HttpServletResponse resp)throws ServletException, IOException { /*如果不覆写doGet方法,就会出现404错误,这是为什么呢?*/ }