`

java.lang.IllegalStateException: ServletConfig has not been initialized

阅读更多
java.lang.IllegalStateException: ServletConfig has not been initialized
at javax.servlet.GenericServlet.getServletContext(GenericServlet.java:197)
at net.wecash.crawler.controller.StartServlet.init(StartServlet.java:20)



这里的代码
	@Override
	public void init(ServletConfig config) throws ServletException
	{
		super.init(config);
		factory=CrawlerUtils.getCrawlerFactory();
		
		this.getServletContext().setAttribute("factory", factory);
		System.out.println("init");
		
	}

之前没有super.inti(config)导致了这个错误。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics