[bs-153] Don't expose classes as resource
Made classpath:/[static,resourecs,public] available instead. Some sample apps had to change so probably some gs-* guides etc as well? [Fixes #51368907]
This commit is contained in:
parent
6c3fd2b2d0
commit
f0d5b8bbe3
|
|
@ -121,16 +121,12 @@ public class WebMvcAutoConfiguration {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||||
// FIXME exposing the root classpath is a security risk
|
registry.addResourceHandler("/resources/**").addResourceLocations("/",
|
||||||
// eg http://localhost:8080/org/springframework/bootstrap/Banner.class
|
"classpath:/META-INF/resources/", "classpath:/resources/",
|
||||||
registry.addResourceHandler("/resources/**").addResourceLocations("/")
|
"classpath:/public/", "classpath:/static/");
|
||||||
.addResourceLocations("classpath:/META-INF/resources/")
|
registry.addResourceHandler("/**").addResourceLocations("/",
|
||||||
.addResourceLocations("classpath:/resources/")
|
"classpath:/META-INF/resources/", "classpath:/resources/",
|
||||||
.addResourceLocations("classpath:/");
|
"classpath:/static/", "classpath:/public/");
|
||||||
registry.addResourceHandler("/**").addResourceLocations("/")
|
|
||||||
.addResourceLocations("classpath:/META-INF/resources/")
|
|
||||||
.addResourceLocations("classpath:/static/")
|
|
||||||
.addResourceLocations("classpath:/");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ public class SampleWebUiApplicationTests {
|
||||||
@Test
|
@Test
|
||||||
public void testCss() throws Exception {
|
public void testCss() throws Exception {
|
||||||
ResponseEntity<String> entity = getRestTemplate().getForEntity(
|
ResponseEntity<String> entity = getRestTemplate().getForEntity(
|
||||||
"http://localhost:8080/css/bootstrap.min.css", String.class);
|
"http://localhost:8080/resources/css/bootstrap.min.css", String.class);
|
||||||
assertEquals(HttpStatus.OK, entity.getStatusCode());
|
assertEquals(HttpStatus.OK, entity.getStatusCode());
|
||||||
assertTrue("Wrong body:\n" + entity.getBody(), entity.getBody().contains("body"));
|
assertTrue("Wrong body:\n" + entity.getBody(), entity.getBody().contains("body"));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue