Java Spring boot更改URL并破坏静态资产
我试图在urlJava Spring boot更改URL并破坏静态资产,java,spring-boot,Java,Spring Boot,我试图在urllocalhost:8080/test 我的目标是点击localhost:8080/test,让它在参考资料目录中呈现index.html页面。目前,当我这样做时,它会将url重定向到localhost:8080并加载内容,然后当我刷新页面时,它会中断“whitepage错误”。我应该如何正确地为这个路径下的my/test url提供静态资产 控制器 @Controller class Welcome { @RequestMapping("/test&qu
localhost:8080/test
我的目标是点击localhost:8080/test
,让它在参考资料目录中呈现index.html
页面。目前,当我这样做时,它会将url重定向到localhost:8080
并加载内容,然后当我刷新页面时,它会中断“whitepage错误”。我应该如何正确地为这个路径下的my/test url提供静态资产
控制器
@Controller
class Welcome {
@RequestMapping("/test")
public String greeting() {
return "index.html";
}
我认为您的文件位于资产下,您已向注册表指定它们位于模板中。尝试将资源添加到指定的路径。
registry
.addResourceHandler("/**")
.addResourceLocations("classpath:/static/templates/")
.setCachePeriod(3000);
}