How can I convert HTTP status code to its text representation, in Java? I mean are there any existing implementations of such a conversion. The best I've found so far is java.ws.rs.core.Response.Status#fromStatusCode()
, which converts only a limited subset of all statuses.
相关问题
- Angular RxJS mergeMap types
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
Apache HttpComponents has an (old-style) enum class which does this:
http://hc.apache.org/httpclient-3.x/apidocs/org/apache/commons/httpclient/HttpStatus.html
You can call its
getStatusText
method with an enum instance as the argument to get the text representation of a status code.Maven dependency is:
If you're happy to import Spring web,
org.springframework.http.HttpStatus.valueOf(int).name()
should do, if you don't mind underscores.