如果一直登录不了,检查一下是不是通过ajax登录的,如果是需要进行如下设置,
If the website uses an ajax call to login. This worked for me. Set this
webClient.setAjaxController(new NicelyResynchronizingAjaxController());
原文链接http://stackoverflow.com/questions/10750301/login-using-htmlunit