
面試被問到如何用Springboot 進行 web開發,看完這篇!怒懟面試官!
- web開發
- 靜態資源
- 首頁
- 一、在靜態資源目錄下新建index.html
- 二、撰寫controller層
- 三、運行測驗
web開發
靜態資源
四個目錄存放的靜態資源可以被我們識別,用來存放我們的html、css、js、圖片等檔案
"classpath:/META-INF/resources/"
"classpath:/resources/"
"classpath:/static/"
"classpath:/public/"
他們的優先級是:resources>static(默認)>public
可以在組態檔中制定靜態資源路徑
#制定靜態資源路徑
spring.mvc.static-path-pattern=/hello/,classpath:/study
首頁
springboot首頁可以放到resources下,也可以放到resources/static或者resources/public都可以
一、在靜態資源目錄下新建index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1>首頁</h1>
</body>
</html>
二、撰寫controller層
@Controller
public class IndexController {
@RequestMapping("/index")
public String index(){
return "index";
}
}
三、運行測驗


分類: [Springboot]
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/293154.html
標籤:其他
