今天httpservlet中调用业务方法,对象总是为空,纠结好久,终于找到解决方法(初始化时,获得bean),特附加代码如下:
@Override
public void init() throws ServletException {
super.init();
ServletContext servletContext = this.getServletContext();
WebApplicationContext ctx = WebApplicationContextUtils
.getWebApplicationContext(servletContext);
advertiseService = (AdvertiseService) ctx.getBean("advertiseService");
}