在使用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);