您可以在Spring Boot应用程序的 application.properties
文件中设置 spring.resources.static-locations
属性来指定静态资源的位置,并使用 spring.mvc.static-path-pattern
属性设置静态资源的URL前缀。
例如,要将所有静态资源路径添加前缀 /static
,您可以添加以下属性到 application.properties
:
spring.resources.static-locations=classpath:/static/
spring.mvc.static-path-pattern=/static/**
这样,您的应用程序将使用 /static
作为所有静态资源的URL前缀,并将查找位于 classpath:/static/
目录中的静态资源。您可以将 classpath:/static/
替换为您想要存储静态资源的目录路径。
希望这可以帮助到您!