在使用HtmlUnit时会出现各种Warnings,如:
七月 30,2013 10:21:36 上午 com.gargoylesoftware.htmlunit.IncorrectnessListenerImplnotify
WARNING: Expectedcontent type of 'application/javascript' or 'application/ecmascript' forremotely loaded JavaScript element at'http://person.sac.net.cn/js/library/Library.js', but got ''.
七月 30,2013 10:21:36 上午 com.gargoylesoftware.htmlunit.IncorrectnessListenerImplnotify
WARNING: Expectedcontent type of 'application/javascript' or 'application/ecmascript' forremotely loaded JavaScript element at'http://person.sac.net.cn/js/library/QueryLibrary.js', but got ''.
这些可以通过一些语句屏蔽掉:
LogFactory.getFactory().setAttribute("org.apache.commons.logging.Log","org.apache.commons.logging.impl.NoOpLog");
java.util.logging.Logger.getLogger("com.gargoylesoftware").setLevel(Level.OFF);
屏蔽掉异常:
webClient.getOptions().setThrowExceptionOnScriptError(false);
webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);