The following are the default configurations of springboot. If you modify the configuration file of springboot, it may not work.
The role of the directory under the resources of springboot
resources/templates
Put the html file (it can only be accessed through the @RequestMapping jump of the control class)
resources/static
Put static resources such as css, js, img
Pithole 1: After springboot starts, the @RequestMapping() annotation of the control class under the controller package cannot jump to the specified html page
Reason one:
The springboot startup class should be placed at the outermost of all packages
Reason two:
Springboot adheres to the principle that the agreement is greater than the configuration. After the project is started, the html page that jumps needs to be placed under the resources/templates directory to successfully jump. The files in this directory are protected and cannot be directly accessed through the web address. .
Reason three:
The @ResponseBody annotation is used on the jump method. After using this annotation, the returned information will be written as a string into the html body area, so the page to be redirected will be written into the body as a string.
Pithole 2: static resources such as css, js, and image cannot be imported after springboot starts.
Reason 1: Springboot accesses these static resources in the resources/static directory. If these style files are not in this directory, the access may not be successful.
Reason 2: The import path has a static directory
Why: By default, springboot imports resources from the resources/static directory to find the path. If you add static, although it is no problem to open locally, you will find that the import of the unsuccessful style file is found when you start the project. At this time, springboot starts to access The path is resources/static/static, of course there is no such directory, so the import will fail.