HttpClient在使用中有两个超时时间 区别
HttpClient在使用中有两个超时时间。
一、连接超时:connectionTimeout
1.指的是连接一个url的连接等待时间。
2.设置方法为:
HttpClient client = new HttpClient();HttpMethod method = new GetMethod("http://test.com"); client.getHttpConnectionManager().getParams().setConnectionTimeout(3000); HttpClient client = new HttpClient();HttpMethod method = new GetMethod("http://localhost:8080/firstTest.htm?method=test");client.getHttpConnectionManager().getParams().setSoTimeout(2000);@RequestMapping(params = "method=test")public String testMethod(ModelMap model) { try { Thread.sleep(3000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println("call testMethod method."); model.addAttribute("name", "test method"); return "test"; }