Spring.mvc.static-path-pattern configuration items in spring boot configuration file

Source: Internet
Author: User

The static resource files in the Spring boot project are stored under the static file, and when these static files are accessed through a browser, it is found that you must add static as a prefix to access, and after a toss, this prefix is followed Spring.mvc.static-path-pattern is related to this configuration item.

Spring:    MVC:        static-path-pattern:/static/**

In the APPLICATION.YML configuration file in the project, when the configuration item is present, accessing the static resource file is static, and when the configuration item is removed, no static prefix can be used for normal access.

When spring boot automatically assembles Org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration, when executed to Org.springframework.boot.autoconfigure.web.WebMvcA Utoconfiguration.webmvcautoconfigurationadapter#addresourcehandlers method, The default value for class Org.springframework.boot.autoconfigure.web.webmvcproperties#staticpathpattern is "/**". If a Spring.mvc.static-path-pattern configuration item exists in the configuration item file, the default configuration item will be overwritten.

When accessed through a browser, SPRINGMVC uses simpleurlhandlermapping for route mapping when executing to a method Org.springframework.web.servlet.handler.abstracturlhandlermapping#lookuphandler, you will use the Spring.mvc.static-path-pattern configuration items to match URLs

Spring.mvc.static-path-pattern configuration items in spring boot configuration file

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.