1024programmer News springBoot stepping on the pit record – continuous update ing

springBoot stepping on the pit record – continuous update ing

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.

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/springboot-stepping-on-the-pit-record-continuous-update-ing/

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索