Welcome resource files and Http common status codes

Welcome resource files

premise:

  The user can remember the name of the website, but not the file name of the website resource

The default welcome resource file:

  When the user sends a [default request] for a certain website,

  At this time, the resource file automatically returned from the current website by the Http server

  Normal request: http://localhost:8080/myWeb/index.

  Default request: http://localhost:8080/myWeb/

Tomcat's locating rules for default welcome resource files

  1) Rule location: Tomcat installation location/conf/web.xml

  2) Rule order:

          <welcome-file-list>

              <welcome-file>index.html</w

              <welcome-file>index.htm</we

              <welcome-file>index.jsp</we

          </welcome-file-list>

Set the default welcome resource file rule for the current website

  1) The location of the rule/web/WEB-INF/web.xml

  2) Rule order:

           <welcome-file-list>

              <welcome-file>user_Login.html</welcome-file>

           </welcome-file-list>

  2) The website has set a custom default file location rule, at this time the location rule that comes with Tomcat will be invalid.

Http status code

Introduction:

  1) A symbol composed of three digits

  2) Before the Http server pushes the response packet, it will process the request according to the situation

      Write the Http status code to the [status line] in the response packet

  3) If the Http server returns the corresponding resource file for this request.

      Inform the browser how to handle this result through the Http status code

      If the Http server is unable to return the corresponding resource file for this request

      Explain to the browser the reason why the service cannot be provided through the Http status code

classification:

  1) Composition: 100-599: divided into five categories

  2)1xx:

      The most characteristic:

          100: Notify the browser of the resource file returned this time

          It is not an independent resource file, it needs the browser to accept

          After responding to the package, 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 and independent resource files, the browser does not need to ask for it after receiving it

          Other related files

  4)3xx:

      The most characteristic:

          302: Notify the browser that what is returned this time is not the content of a resource file

          It is the address of a resource file, and the browser needs to automatically initiate a request based on this address

          Request this resource file

      response.sendRedirect("the address of the resource file"); write the location in the response header

      And this behavior causes Tomcat to write 302 to the status line

  5)4xx:

      The most characteristic:

          404: Notify the browser that the resource file to be accessed is not located in the server

          So unable to provide relevant help

          405: Notify the browser that the accessed resource file (Servlet) has been located in the server

          But this Servlet cannot handle the request method used by the browser

  6)5xx:

      The most characteristic:

          500: Notify the browser that the accessed resource file (Servlet) has been located in the server

          This servlet can receive the request method used by the browser, but the servlet is processing the request

          During the period, it failed due to a Java exception.

 

 

 

 

 

 

Guess you like

Origin blog.csdn.net/qq_45796208/article/details/108712342