java线程调用方法传值报空指针
public void getWebPage() throws IOException, ParseException{
SearchCrawler seaCrawler = new SearchCrawler();
for(CrawlSiteModel csm:siteList){
List<Map<String , Object>> resultNews = new ArrayList<Map<String , Object>>();
String urlRules = csm.getSiteUrlRules();
String startUrl = csm.getSiteUrl();
Map<String ,Object> textLab = new HashMap<String ,Object>();
textLab.put("contentLab", csm.getSiteTextLab());
textLab.put("titleLab", csm.getSiteTitleLab());
textLab.put("pubTimeLab", csm.getSitePubTimeLab());
textLab.put("publisherLab", csm.getSitePublisherLab());
resultNews = seaCrawler.crawl(startUrl, urlRules, textLab);
cSertvice.saveNews(resultNews,csm);//此处报空指针
}
}
public void run(){
try {
System.out.println("StartThread");
getWebPage();
} catch (Exception e) {
e.printStackTrace();
}
}