當(dāng)前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
Spring Boot中使用模板引擎引用资源
生活随笔
收集整理的這篇文章主要介紹了
Spring Boot中使用模板引擎引用资源
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
目錄
?
概念
演示
?
概念
在Spring Boot中可以通過模板引擎去引用資源,如果項目改變了,也是可以跑的,不需要自己手動一個個去改鏈接。
?
演示
運行截圖如下:
但修改properties文件:
server.context-path=/crud運行截圖如下:
其中l(wèi)ogin.html如下:
<!DOCTYPE html> <html lang="en" xmlns:th="http://www.thymeleaf.org"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><meta name="description" content=""><meta name="author" content=""><title>Signin Template for Bootstrap</title><!-- Bootstrap core CSS --><link href="asserts/css/bootstrap.min.css" th:href="@{/webjars/bootstrap/4.0.0/css/bootstrap.css}" rel="stylesheet"><!-- Custom styles for this template --><link href="asserts/css/signin.css" th:href="@{/asserts/css/signin.css}" rel="stylesheet"></head><body class="text-center"><form class="form-signin" action="dashboard.html"><img class="mb-4" th:src="@{/asserts/img/bootstrap-solid.svg}" src="asserts/img/bootstrap-solid.svg" alt="" width="72" height="72"><h1 class="h3 mb-3 font-weight-normal">Please sign in</h1><label class="sr-only">Username</label><input type="text" class="form-control" placeholder="Username" required="" autofocus=""><label class="sr-only">Password</label><input type="password" class="form-control" placeholder="Password" required=""><div class="checkbox mb-3"><label><input type="checkbox" value="remember-me"> Remember me</label></div><button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button><p class="mt-5 mb-3 text-muted">? 2017-2018</p><a class="btn btn-sm">中文</a><a class="btn btn-sm">English</a></form></body></html>關(guān)鍵代碼如下:
總結(jié)
以上是生活随笔為你收集整理的Spring Boot中使用模板引擎引用资源的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Spring Boot静态资源映射规则
- 下一篇: Spring Boot中使用模板引擎参数