从org.apache.http.HttpResponse获取HTTP代码 [英] Get HTTP code from org.apache.http.HttpResponse
本文介绍了从org.apache.http.HttpResponse获取HTTP代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Java应用程序中使用org.apache.http.HttpResponse
类,并且我需要能够获取HTTP状态代码.如果在其上使用.toString()
,则可以在其中看到HTTP状态代码.还有什么其他功能可以让我以int或String形式获取HTTP状态代码?
I'm using the org.apache.http.HttpResponse
class in my Java application, and I need to be able to get the HTTP status code. If I used .toString()
on it, I can see the HTTP status code in there. Is there any other function that I can just get the HTTP status code as either an int or String?
感谢一堆!
推荐答案
Use HttpResponse.getStatusLine()
, which returns a StatusLine
object containing the status code, protocol version and "reason".
这篇关于从org.apache.http.HttpResponse获取HTTP代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文