Home > Back-end >  How to modify the HTTP status text in spring
How to modify the HTTP status text in spring

Time:03-10

Such as general reply 200 OK, I want to change to 200 Success do
400 Bad Request I want to change to 400 user id is required do
I need this function implementation class apns response

CodePudding user response:

Haven't seen this kind of change to httpstatus, can through the global exception handling, return json, json return code and message can realize your capabilities

CodePudding user response:

Spring didn't studied, native can
 
HttpURLConnection connection=(HttpURLConnection) new URL (" http://www.baidu.com "). The openConnection ();
.
If (connection. GetResponseCode ()==HttpURLConnection. HTTP_OK) {
Return "Success";
}

CodePudding user response:

refer to the second floor of snow crystal reply:
spring didn't studied, native can

You this is the client, I am the service side return

CodePudding user response:

reference 1st floor a1767028198 response:
never seen this kind of change to httpstatus, can through the global exception handling, return json, json return code and message, can realize the function you

Indeed, most use this way

CodePudding user response:

reference kathy_koo reply: 3/f
Quote: refer to the second floor of snow crystal reply:
spring didn't studied, native can

You this is the client, I am the service side return


Server will not change unless you don't have to HTTP or HTTPS

CodePudding user response:

reference 1st floor a1767028198 response:
never seen this kind of change to httpstatus, can through the global exception handling, return json, json return code and message, can realize the function you

I realize pseudo apns, must return to deal with apns consistent apns to modify the status message, I will have to modify

CodePudding user response:

refer to 6th floor kathy_koo response:
Quote: refer to 1st floor a1767028198 response:
never seen this kind of change to httpstatus, can through the global exception handling, return json, json return code and message, can realize the function you

I realize pseudo apns, must return to deal with apns consistent apns to modify the status message, I will have to modify

Do you have a different interface it returns caught?

By definition if fancy here, destroy the agreement

CodePudding user response:

refer to 7th floor a1767028198 response:
Quote: refer to the sixth floor kathy_koo response:
Quote: refer to 1st floor a1767028198 response:
never seen this kind of change to httpstatus, can through the global exception handling, return json, json return code and message, can realize the function you

I realize pseudo apns, must return to deal with apns consistent apns to modify the status message, I will have to modify

Do you have a different interface it returns caught?

By definition if fancy here, will destroy the agreement

Because my logic and different apns so apns authentication through I may not pass, but need to be consistent with apns agreement to return to the downstream
Nignx can write so, PHP, the.net golang, I can write, spring matter, I don't know how to write

CodePudding user response:

refer to 7th floor a1767028198 response:
Quote: refer to the sixth floor kathy_koo response:
Quote: refer to 1st floor a1767028198 response:
never seen this kind of change to httpstatus, can through the global exception handling, return json, json return code and message, can realize the function you

I realize pseudo apns, must return to deal with apns consistent apns to modify the status message, I will have to modify

Do you have a different interface it returns caught?

By definition if fancy here, will destroy the agreement

I billions of devices, optimization in the agreement is worth, because I can save a lot of bandwidth
  • Related