這是Day5,一樣使用此教材:
尚硅谷IT培训学校: https://www.youtube.com/watch?v=gt6QgrSuTcQ&list=PLmOn9nNkQxJEeIH75s5pdTUnCo9-xOc7c&index=38
C:\Users\user\.m2\repository\org\springframework\boot\spring-boot-autoconfigure\3.2.2\spring-boot-autoconfigure-3.2.2-sources.jar!\org\springframework\boot\autoconfigure\thymeleaf\ThymeleafProperties.java
public static final String DEFAULT_PREFIX = "classpath:/templates/";
public static final String DEFAULT_SUFFIX = ".html";
Thymeleaf:
用RestController和Controller的差異
<h1 th:utext="${name}"></h1>
會轉譯HTML
<img th:src="${URL}"></img>
URL: '/test.jpg'
<img th:attr="src=${URML},style=${style}"></img>
合併
<img th:if="${show}"></img>
model.addAttribute("show", true);
@{} URL路徑
server.servlet.context-path=/demo
<h1 th:text="${#string.toUpperCase(name)}"></h1>
th:each
沒有留言:
張貼留言