Status code

Status code

Introduction

  • A symbol composed of three digits.

  • Before the http server pushes the response package , it writes the http status code to the [status line] in the response package according to the processing of this request

  • effect:

    • If the http server returns the corresponding resource file for this request, the HTTP status code is used to inform the browser how to handle the result.

    • If the http server fails to return the corresponding resource file for this request, explain the reason why the service cannot be provided to the browser through the http status code

classification

  1. Composed of 100-599 divided into five major categories

  2. 1xx: The most characteristic 100: Notify the browser that the resource file returned this time is not an independent resource file . After receiving the response packet, the browser needs to continue to ask the http server for other resource files that it depends on.

  3. ​ 2xx: The most characteristic 200: Notify the browser that the resource file returned this time is a complete independent resource file. After the browser receives it, it does not need to continue to ask for other resource files from the http server.

  4. 3xx: The most characteristic 302: Notify the browser that what is returned this time is not the content of a resource file , but the address of a resource file. The browser needs to automatically initiate a request based on this address to request this resource file.

    response.sendRedirect("resource file address") is written to the location in the response header. This behavior causes Tomcat to write the 302 status code to the status line.

    After the browser receives the response packet, because of the 302 status code, the browser will not read the content of the response body, and automatically initiate a second request based on the location address in the response header

  5. 4xx :

    404: Notify the browser that because the resource file to be accessed is not located on the server, the corresponding resource cannot be provided.

    405: Notify the browser that the resource file (servlet) to be accessed has been located on the server, but the servlet cannot process the request method adopted by the browser. post get

  6. 5xx:

    500: Notify the browser that the resource file (servlet) to be accessed has been located on the server. This servlet can receive the request method used by the browser, but the servlet failed due to a java exception during the processing of the request.

Guess you like

Origin blog.csdn.net/weixin_43903813/article/details/114007480