无意 中看到java.Servlet.GenericServlet中有两个init方法 不知何解。
init(ServletConfig config)
Called by the servlet container to indicate to a servlet that the servlet is being placed into service.
init()
A convenience method which can be overridden so that there's no need to call super.init(config)
.
根据注解并查看源代码:第一个方法是servlet 容器 所调用,并取得config 的值,调用第二个init() 方法。开发人员只需要调用第二个init ()方法即可。