當前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
Spring Boot CLI 入门项目
生活随笔
收集整理的這篇文章主要介紹了
Spring Boot CLI 入门项目
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
看此文;
https://blog.csdn.net/bcbobo21cn/article/details/109063292
運行spring boot cli程序;運行了如下;
?
訪問網頁看到如下;?
下面來做一個入門項目;創建如下目錄和文件;?
用 tree /f 看一下,一共三個文件;其中2個html;
命令行輸入 echo. > a.txt,創建一個空的a.txt;?
代碼如下;
?groovy文件;
@Controller @Grab('spring-boot-starter-thymeleaf') class MessageController {@RequestMapping("/message")String getMessage(Model model) {String msg = "first spring boot test ;make by bo;";model.addAttribute("msg", msg);return "msg";} }index.html;
<!DOCTYPE HTML> <html><head> <title>Spring Boot CLI Example</title> <meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8" /></head><body><p>Go to <a href = "/msg">Message</a></p></body> </html>msgbo.html;
<!DOCTYPE HTML> <html xmlns:th = "http://www.thymeleaf.org"><head> <title>Spring Boot CLI Example</title> <meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8" /></head><body> <p th:text = "'Message: ' + ${msg}" /></body> </html>?啟動spring boot cli,運行message.groovy;
?
跑起來以后;看網頁,localhost:8080,出現下圖;?
然后點Message鏈接;應該出來這串,?"first spring boot test ?;make by bo;"? ?;
網絡不太好,如下;下回繼續;
?
《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀總結
以上是生活随笔為你收集整理的Spring Boot CLI 入门项目的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 通过超图在网页上加载obj格式3D模型
- 下一篇: Java虚拟机new和newarray相