可以添加代码如下:
1 WebClient client = new WebClient(); 2 3 client.setIncorrectnessListener(new SilentIncorrectnessListener()); 4 //js异常控制主要的一步 5 client.getOptions().setJavaScriptEnabled(false); 6 client.setCssErrorHandler(new QuietCssErrorHandler()); 7 client.getOptions().setThrowExceptionOnScriptError(false); 8 9 client.getOptions().setThrowExceptionOnFailingStatusCode(false); 10 //设置日志级别 11 java.util.logging.Logger.getLogger("com.gargoylesoftware").setLevel(Level.OFF);