Servlet中调用Spring bean报错
解决方法:
Service层
@Service(value="webuserManagerImpl")
public class WebuserManagerImpl implements WebuserManager {
...
}
在Servlet的doPost方法中加入
WebApplicationContext wc = WebApplicationContextUtils.getWebApplicationContext(request.getSession().getServletContext());
WebuserManager service = (WebuserManager) wc.getBean("webuserManagerImpl");
service.方法
解决方法:
Service层
@Service(value="webuserManagerImpl")
public class WebuserManagerImpl implements WebuserManager {
...
}
在Servlet的doPost方法中加入
WebApplicationContext wc = WebApplicationContextUtils.getWebApplicationContext(request.getSession().getServletContext());
WebuserManager service = (WebuserManager) wc.getBean("webuserManagerImpl");
service.方法