http://blog.csdn.net/u010989191/article/details/52852155
**********************************************************
@RequestMapping (value= "/xxxxx/authenticate") Public@ResponseBody string GetToken (@RequestParam string username, @RequestParam string password)throwsException {InputStream is=NULL; BufferedReader BR=NULL; StringBuilder Sbuilder=NULL; Try{HttpClient HttpClient=Newdefaulthttpclient (); Httpput Httpput=NewHttpput ("url"); Httpput.addheader ("Username", username); Httpput.addheader ("Password", password); HttpResponse HttpResponse=Httpclient.execute (httpput); //Connection Successful if(200 = =httpresponse.getstatusline (). Getstatuscode ()) {httpentity httpentity=httpresponse.getentity (); is=httpentity.getcontent (); BR=NewBufferedReader (NewInputStreamReader (IS)); String TempStr; Sbuilder=NewStringBuilder (); while((TempStr = Br.readline ())! =NULL) {sbuilder.append (TEMPSTR); } br.close (); Is.close (); } }Catch(Exception e) {System.out.println (e); E.printstacktrace (); } returnsbuilder==NULL? "": Sbuilder.tostring (); }
Jar Package Required: http://download.csdn.net/detail/u010989191/9657039
[Java]--httpclient send put request