1

我收到大量消息,例如:

2015-02-13 10:24:13,487 ERROR [JS executor for com.gargoylesoftware.htmlunit.WebClient@1ca81e44] [] [@@@] [] StrictErrorReporter.runtimeError(80) | runtimeError: message=[An invalid or illegal selector was specified (selector: '#activityListDateFilter:_activityDateFilterTabView #activityListDateFilter\:_periodTab_month' error: Invalid selector: *#activityListDateFilter:_activityDateFilterTabView *#activityListDateFilter:_periodTab_month).] sourceName=[http://localhost:8080/javax.faces.resource/jquery/jquery.js.html?ln=primefaces&rv=20158] line=[23] lineSource=[null] lineOffset=[0]
2015-02-13 10:24:13,573 ERROR [JS executor for com.gargoylesoftware.htmlunit.WebClient@1ca81e44] [] [@@@] [] StrictErrorReporter.runtimeError(80) | runtimeError: message=[An invalid or illegal selector was specified (selector: '#activityTable:_activities th .ui-column-filter[onkeyup]' error: Invalid selector: *#activityTable:_activities th *.ui-column-filter[onkeyup]).] sourceName=[http://localhost:8080/javax.faces.resource/jquery/jquery.js.html?ln=primefaces&rv=20158] line=[23] lineSource=[null] lineOffset=[0]
2015-02-13 10:24:13,614 ERROR [JS executor for com.gargoylesoftware.htmlunit.WebClient@1ca81e44] [] [@@@] [] StrictErrorReporter.runtimeError(80) | runtimeError: message=[An invalid or illegal selector was specified (selector: '#__sizzle__  > li:has(a[href])' error: Invalid selectors: #__sizzle__  > li:has(a[href])).] sourceName=[http://localhost:8080/javax.faces.resource/jquery/jquery.js.html?ln=primefaces&rv=20158] line=[23] lineSource=[null] lineOffset=[0]

有没有办法禁用所有这些?

4

2 回答 2

1

尝试将此添加到您的代码中:

LogFactory.getFactory().setAttribute("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.NoOpLog");

java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit").setLevel(Level.OFF); 
java.util.logging.Logger.getLogger("org.apache.commons.httpclient").setLevel(Level.OFF);

webClient = new WebClient(bv);
webClient.setCssEnabled(false);

webClient.setIncorrectnessListener(new IncorrectnessListener() {

    @Override
    public void notify(String arg0, Object arg1) {
        // TODO Auto-generated method stub

    }
});
webClient.setCssErrorHandler(new ErrorHandler() {

    @Override
    public void warning(CSSParseException exception) throws CSSException {
        // TODO Auto-generated method stub

    }

    @Override
    public void fatalError(CSSParseException exception) throws CSSException {
        // TODO Auto-generated method stub

    }

    @Override
    public void error(CSSParseException exception) throws CSSException {
        // TODO Auto-generated method stub

    }
});
webClient.setJavaScriptErrorListener(new JavaScriptErrorListener() {

    @Override
    public void timeoutError(HtmlPage arg0, long arg1, long arg2) {
        // TODO Auto-generated method stub

    }

    @Override
    public void scriptException(HtmlPage arg0, ScriptException arg1) {
        // TODO Auto-generated method stub

    }

    @Override
    public void malformedScriptURL(HtmlPage arg0, String arg1, MalformedURLException arg2) {
        // TODO Auto-generated method stub

    }

    @Override
    public void loadScriptError(HtmlPage arg0, URL arg1, Exception arg2) {
        // TODO Auto-generated method stub

    }
});
webClient.setHTMLParserListener(new HTMLParserListener() {

    @Override
    public void warning(String arg0, URL arg1, int arg2, int arg3, String arg4) {
        // TODO Auto-generated method stub

    }

    @Override
    public void error(String arg0, URL arg1, int arg2, int arg3, String arg4) {
        // TODO Auto-generated method stub

    }
});

webClient.setThrowExceptionOnFailingStatusCode(false);
webClient.setThrowExceptionOnScriptError(false);
于 2015-02-13T09:35:47.620 回答
1

只需使用以下代码行并检查

java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit").setLevel(Lev‌​el.OFF);
于 2015-02-13T09:20:11.223 回答