當前位置:編程學習大全網 - 網站源碼 - springboot啟動後為什麽會訪問index

springboot啟動後為什麽會訪問index

如果不作任何配置,在static或templates文件夾中放入index.html,會自動跳轉index.html

原因:

(4條消息) Spring Boot 默認跳轉到index.html的二種方式_NULL-CSDN博客_springboot 默認index.html

2. 在controller中配置

@GetMapping("/")

public String index(){

return "index";

}

應該使用@Controller而非@RestfulController,並且index.html需要放在templates文件夾中

3. 參考:(4條消息) Spring Boot 默認跳轉到index.html的二種方式_NULL-CSDN博客_springboot 默認index.html

@Configuration

public class MyMvcConfig implements WebMvcConfigurer {

  • 上一篇:ERP是什麽貨幣。微軟官網上有
  • 下一篇:什麽是拆裝,具體目的是什麽?
  • copyright 2024編程學習大全網