摘要:創(chuàng)建工程涉及了,加上和的起步依賴。創(chuàng)建實(shí)體代碼清單如下創(chuàng)建頁(yè)面展示層啟動(dòng)工程,訪問(wèn)點(diǎn)擊參考資料源碼下載
這篇文件主要介紹通過(guò)springboot 去創(chuàng)建和提交一個(gè)表單。
創(chuàng)建工程涉及了 web,加上spring-boot-starter-web和spring-boot-starter-thymeleaf的起步依賴。
創(chuàng)建實(shí)體org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-test test org.springframework.boot spring-boot-starter-thymeleaf
代碼清單如下:
public class Greeting { private long id; private String content; public long getId() { return id; } public void setId(long id) { this.id = id; } public String getContent() { return content; } public void setContent(String content) { this.content = content; } }創(chuàng)建Controller
@Controller public class GreetingController { @GetMapping("/greeting") public String greetingForm(Model model) { model.addAttribute("greeting", new Greeting()); return "greeting"; } @PostMapping("/greeting") public String greetingSubmit(@ModelAttribute Greeting greeting) { return "result"; } }頁(yè)面展示層
src/main/resources/templates/greeting.html
Getting Started: Handling Form Submission Form
src/main/resources/templates/result.html
Getting Started: Handling Form Submission Result
Submit another message
啟動(dòng)工程,訪問(wèn)ttp://localhost:8080/greeting:
點(diǎn)擊submit:
參考資料https://spring.io/guides/gs/h...
源碼下載https://github.com/forezp/Spr...
文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請(qǐng)注明本文地址:http://m.hztianpu.com/yun/71443.html
摘要:建一個(gè)單元測(cè)試類其中,注解開啟了生成文件,并指定了存放位置。怎么用創(chuàng)建一個(gè)新文件用構(gòu)建文檔這個(gè)例子非常簡(jiǎn)單,通過(guò)單元測(cè)試和一些簡(jiǎn)單的配置就能夠得到文檔了。 準(zhǔn)備工作 你需要15min Jdk 1.8 maven 3.0+ idea 創(chuàng)建工程 引入依賴,其pom文件: org.springframework.boot spring-boot-...
這篇文章主要介紹如何在springboot中如何創(chuàng)建含有多個(gè)module的工程,栗子中含有兩個(gè) module,一個(gè)作為libarary. 工程,另外一個(gè)是主工程,調(diào)用libary .其中l(wèi)ibary jar有一個(gè)服務(wù),main工程調(diào)用這個(gè)服務(wù)。 創(chuàng)建根工程 創(chuàng)建一個(gè)maven 工程,其pom文件為: 4.0.0 com.forezp springboot-multi-...
摘要:是一個(gè)開源的應(yīng)用容器引擎,基于語(yǔ)言并遵從協(xié)議開源。準(zhǔn)備工作環(huán)境環(huán)境或不要用對(duì)一無(wú)所知的看教程。創(chuàng)建一個(gè)工程引入的起步依賴,創(chuàng)建一個(gè)將工程容器化有一個(gè)簡(jiǎn)單的文件作為指定鏡像的圖層。說(shuō)明的工程已部署。停止鏡像刪除鏡像參考資料源碼下載 這篇文篇介紹,怎么為 springboot程序構(gòu)建一個(gè)docker鏡像。docker 是一個(gè)開源的應(yīng)用容器引擎,基于 Go 語(yǔ)言 并遵從Apache2.0協(xié)議...
閱讀 994·2021-11-08 13:22
閱讀 2936·2021-09-29 09:45
閱讀 2894·2021-09-09 11:52
閱讀 2323·2019-08-30 13:20
閱讀 3835·2019-08-29 13:28
閱讀 1437·2019-08-29 12:32
閱讀 2811·2019-08-29 11:10
閱讀 1701·2019-08-26 13:34