Reputation:
I have studied about spring, especially spring-boot.
So I made a project, set config into this project. But I didn't know spring well.
So I searched these things, just copied the codes.
And now I find a strange thing that I mentioned in title. Please see below codes.
@Configuration
@EnableWebMvc
public class WebMVCAutoConfig implements WebMvcConfigurer{
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/*")
.addResourceLocations("classpath:/static/");
//I used this for get some images out of the project.
registry.addResourceHandler("/external/**")
.addResourceLocations("file:D:///resource/");
}
}
As you can see, both 'addResourceHandler' have * in argument.
But I can not understand why I have to use two * in bottom-code.
From I write this codes, When I access by http://localhost:port/pre-setting-url, It works.
But If I use only one * in bottom-code, pre-setting-url are not work. I can not get images.
I know the meaning of * as 'all', But it is not?
What is the meaning of * and **
Help me!
thank you.
Upvotes: 0
Views: 148
Reputation: 19451
/*
means any resource directly under / like /foo or /bar, but not /foo/something.
**
also includes subresources, so /external/**
matches /external/foo/something or /external/foo/somethingelse.
Upvotes: 1