Rewriting addResourceHandlers under spring boot cannot be accessed

When I first started learning springboot, I was unable to access the static resources when calling the static resources. The reason was that the static files were in the wrong directory. They were not created under main/resources, but were created directly in the project root directory.

package org.myboot.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
public class WebAppConfigurer extends WebMvcConfigurerAdapter{
	
	@Override
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
		registry.addResourceHandler("/myfile/**").addResourceLocations("classpath:/myfile/");
		super.addResourceHandlers(registry);
	}
	
}

  Correct directory :
 

  Error directory:
 
 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326227295&siteId=291194637