博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
企业级 SpringBoot 教程 (二十)处理表单提交
阅读量:7113 次
发布时间:2019-06-28

本文共 1556 字,大约阅读时间需要 5 分钟。

这篇文件主要介绍通过springboot 去创建和提交一个表单。

创建工程

涉及了 web,加上spring-boot-starter-web和spring-boot-starter-thymeleaf的起步依赖。

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;    }}

  

创建Controller

@Controllerpublic 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";    }}

  

页面展示层

src/main/resources/templates/greeting.html

    Getting Started: Handling Form Submission    

Form

Id:

Message:

  

架构代码如下 :

"分布式b2b <wbr

 

转载于:https://www.cnblogs.com/xiamudaren/p/8416589.html

你可能感兴趣的文章
解决Agent admitted failure to sign using the kye with ssh
查看>>
Linux Doxygen的安装和使用
查看>>
android adb介绍
查看>>
【SQL】SQL中笛卡尔积、内连接、外连接的数据演示
查看>>
HTTP解析
查看>>
MemCache超详细解读
查看>>
python numpy 教程
查看>>
手机web如何实现多平台分享
查看>>
策略模式和观察者模式
查看>>
详解CALayer 和 UIView的区别和联系
查看>>
eclipse中报错:java.lang.OutOfMemoryError: Java heap space
查看>>
Ubuntu 16.04 grub rescue 模式下修复 grub
查看>>
【Spring】24、<load-on-startup>0</load-on-startup>配置
查看>>
L0 Regularization
查看>>
使用JDBC向Kudu表插入中文数据乱码(转载)
查看>>
spf13-vim安装与使用
查看>>
字体颜色代码表
查看>>
hdu 2156 分数矩阵
查看>>
android SQLite数据库应用于草稿箱
查看>>
Android 无缝换肤深入了解与使用
查看>>