我正在测试Spring处理路由和静态资源的方式,我无法弄清楚为什么加载静态资源要比加载整个控制器花费更多的时间,甚至找不到错误404页面。.>
public class HomepageController {
@RequestMapping("/")
public String homepageLoader() {
return "homepage.html";
}
}
public class DefaultViewConfig implements WebMvcConfigurer {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/home").setViewName("/homepage.html");
registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/static.html").addResourceLocations("classpath:/static/");
registry.addResourceHandler("/statik/**").addResourceLocations("classpath:/statik/");
}
}