springboot(10)- 整合web开发(2)- 静态资源访问

    技术2024-10-25  23

    1 静态资源访问

    2 两种方式自定义静态资源访问位置

    2.1 方式1

    2.2 方式2

    package com.tzb.config; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @Configuration public class WebMvcConfig implements WebMvcConfigurer { @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/**") .addResourceLocations("classpath:/mylocation/"); } }
    Processed: 0.009, SQL: 9