5、配置首頁
server.servlet.context-path=/jinhua
4、thymleaf 數組
3、一個簡單spring boot的thmleaf引擎
2、thymleaf模板引擎
thymleaf配置類中,指定了前綴和後腿(spring的視圖解析器需手動配置,springboot的thymeleaf 自動配置好),我們只需導入對應的依賴即可使用該模板。
依賴:
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring5</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-java8time</artifactId>
</dependency>
使用:templates中保存 html頁面,controller 類 返回到頁面
1、項目中如下4個路徑下可存放靜態資源
@ConfigurationProperties(prefix = "spring.resources", ignoreUnknownFields = false)
public class ResourceProperties {
private static final String[] CLASSPATH_RESOURCE_LOCATIONS = { "classpath:/META-INF/resources/",
"classpath:/resources/", "classpath:/static/", "classpath:/public/" };
可以在項目中創建如下文件,存放靜態資源,默認有classpath:/static/路徑
訪問的優先級:resources > static > public