读spring mvc 源码
先看看关键servlet:DispatcherServlet的继承结构图 我们先从GenericServlet这个类看起。 1.这个类实现了servlet接口 2.看关键代码 public void init(ServletConfig config) throws ServletException { this.config = config; this.init(); } public void init() throws ServletException { } 这里init(ServletConfig config)是实现servlet的方法,init()是新建的方法。 而由于实现的方法里面,调用了init()这个方法,所以后续继承了GenericServlet 这个类的类,只要重写init()方法,即可对servlet的初始化部分进行修改。 我们再来看HttpServletBean这个类。 1.看关键代码 public final void init() throws ServletException { if (this.logger.isDebugEnabled()) { this.logger.debug("Initializing servlet '" + this.getServletName() + "'"); } try { PropertyValues