尝试这个。它对我有用:
class InterceptWebConnection extends FalsifyingWebConnection{
public InterceptWebConnection(WebClient webClient) throws IllegalArgumentException{
super(webClient);
}
@Override
public WebResponse getResponse(WebRequest request) throws IOException {
WebResponse response=super.getResponse(request);
if(response.getWebRequest().getUrl().toString().endsWith("dom-drag.js")){
return createWebResponse(response.getWebRequest(), "", "application/javascript", 200, "Ok");
}
return super.getResponse(request);
}
}
然后在设置你的时候写下webClient
new InterceptWebConnection(webClient);