HttpServletBean 主要参与创建工作,并没有涉及到请求的处理.
public abstract class HttpServletBean extends HttpServlet implements EnvironmentCapable, EnvironmentAware {
//此方法是springmvc入口方法
public final void init() throws ServletException {
//将servlet中配置的参数加载到pvs中
PropertyValues pvs = new HttpServletBean.ServletConfigPropertyValues(this.getServletConfig(), this.requiredProperties);
if (!pvs.isEmpty()) {
try {
BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(this);
ResourceLoader resourceLoader = new ServletContextResourceLoader(this.getServletContext());
bw.registerCustomEditor(Resource.class, new ResourceEditor(resourceLoader, this.getEnvironment()));
this.initBeanWrapper(bw);
bw.setPropertyValues(pvs, true);
} catch (BeansException var4) {
if (this.logger.isErrorEnabled()) {
this.logger.error("Failed to set bean properties on servlet '" + this.getServletName() + "'", var4);
}
throw var4;
}
}
//模板方法 ,通过子类进行一些初始化工作
this.initServletBean();
}
}
参考资料:看透springmvc源码