標籤:color ring 輸入 static set root org resources username
1.Springboot
a.定義:Spring Boot是由Pivotal團隊提供的全新架構,其設計目的是用來簡化新Spring應用的初始搭建以及開發過程
b.約定目錄結構:(Maven的資源檔目錄/src/java/resources中)
spring-boot項目靜態檔案目錄:/src/java/resources/static(一般放img、css、js等)
spring-boot項目模板檔案目錄:/src/java/resources/templates(一般放html檔案)
2.使用
a.Controller中
@GetMapping("/") //輸入路徑http://127.0.0.1:8080/ 即可訪問到 public String index(){ return "index"; } @GetMapping("/loginPapge") public String loginPapge(){ return "login"; }
b.html中
<!DOCTYPE html><html lang="en" xmlns:th="http://www.thymeleaf.org"><head> <meta charset="UTF-8"/> <title>Title</title></head><body>歡迎你:<span th:text="${session.user.getUserName()}"></span> <table> <tr> <th>id</th> <th>姓名</th> <th>密碼</th> <th>狀態</th> </tr> <tr th:each="user,userStat: ${users}"> <td th:text="${user.userId}"></td> <td th:text="${user.userName}"></td> <td th:text="${user.userPwd}"></td> <td th:text="${user.userType}"></td> </tr> </table></body></html>
c.如需使用Spring Data Jpa,需在/src/java/resources中配置application.yml
spring: thymeleaf: cache: false datasource: username: root url: jdbc:mysql://127.0.0.1:3306/j135 driver-class-name: com.mysql.jdbc.Driver password: admin jpa: show-sql: true database-platform: org.hibernate.dialect.MySQL5Dialect
JavaEE 之 SpringBoot