In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the knowledge of "how spring boot accesses external static resource pictures under Linux". Many people will encounter this dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Static resource mapping
1. The method of modifying static resource mapping:
Spring.mvc.static-path-pattern=/mystatic/* # here sets the url-patternspring.resources.static-locations= classpath:mystatic/# for static resource matching. Here you set the path to point to. Multiple paths are separated by English commas, and the priority is high in the front.
2. The method of code mapping:
/ * Created by @ author LiuChunhang on 2020-6-16. * / @ Configurationpublic class MyWebMvcConfigurer implements WebMvcConfigurer {@ Override public void addResourceHandlers (ResourceHandlerRegistry registry) {/ / that is, when a resourceHandler match occurs in url, it is mapped to location. When location is equivalent to a virtual path / / mapping a local file, it must begin with file:///. Represents the protocol / / registry.addResourceHandler ("picture/**") .addResourceLocations ("/ root/picture/") System.out.println ("static requests are mapped to external resources via virtual paths"); registry.addResourceHandler ("/ view/**") .addResourceLocations ("file://");}})
Note: you can also set the external disk directory in the same way as follows: file:d/mystatic/.
This is the end of the content of "how to access external static Resources Pictures under spring boot under Linux". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.