之前SSM框架,里面有webapps文件夾,用來存放前端頁面和各種前端資源,現在SpringBoot中沒有webapps文件夾,springboot結構如下:
第一、resourses下文件夾public是我自己創建的,通過local host:8080/index.html可以直接訪問。
第二、通過controller層訪問templates中的文件夾:
步驟一、application.properties 配置中添加spring.thymeleaf.prefix=classpath:/templates/
步驟二、pom.xml文件中添加依賴:
<!-- 訪問html文件依賴begin --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> <!-- 訪問html文件依賴begin -->
步驟三、controller層訪問http://localhost:8080/test :
打完收工。