首页 > 其他分享 >springboot的form表单数据封装为对象

springboot的form表单数据封装为对象

时间:2022-10-18 00:45:03浏览次数:92  
标签:index springboot form 表单 Blog result String

参考:(68条消息) spring boot (五)表单处理_2020越努力越幸运的博客-CSDN博客_springboot表单

 

    @GetMapping("/index")
    public String blog(Model model)
    {
        model.addAttribute("blogs",new Blog());
        return "index";
    }

  index.html

    <form action="#" th:action="@{/blogs/result}" th:object="${blogs}" method="post">
        <input type="text" th:field="*{id}">
        <input type="text" th:field="*{content}">
        <input type="submit" value="提交">
    </form>

  

     @PostMapping("/blogs/result")
    public String create(@ModelAttribute Blog blog)
    {
        return "result";
        
    }

  

标签:index,springboot,form,表单,Blog,result,String
From: https://www.cnblogs.com/huaobin/p/16801219.html

相关文章

  • SpringBoot的多种事件监听机制
    前置配置#META-INF/spring.factories文件配置#ApplicationContextInitializerorg.springframework.context.ApplicationContextInitializer=com.test.springbootdemo......
  • springboot连接mysql报错errorCode 0, state 08S01
    前言许久未维护的项目需要检查一些数据,重新运行项目发现有createconnectionSQLException,具体报错信息是errorCode0,state08S01。SpringBoot版本2.5,MySQL8.0报......
  • 面经:什么是Transformer位置编码?
     Datawhale干货 作者:陈安东,中央民族大学,Datawhale成员过去的几年里,Transformer大放异彩,在各个领域疯狂上分。它究竟是做什么,面试常考的Transformer位置编码暗藏什么玄机?本......
  • ABAP SMARTFORMS和函数_1
                              自定义上传图片       ......
  • 基于springboot学生公寓管理系统-计算机毕业设计源码+LW文档
    摘要:本学生公寓管理系统是针对目学生公寓管理的实际需求,从实际工作出发,对过去的学生公寓管理系统存在的问题进行分析,完善学生的使用体会。采用计算机系统来管理信息,取代人工......
  • SpringBoot源码解析ApplicationEnvironmentPreparedEvent
    转自:https://blog.csdn.net/m0_37298252/article/details/122355631最近两篇文章主要分析了ConfigFileApplicationListener对事件ApplicationEnvironmentPreparedEvent的......
  • CSharp: Detection Platform in donet core 6
     //win1064位电脑测试c#10.netcore6Console.WriteLine("HellofromaTopLevelProgram!");Console.WriteLine(Environment.OSVersion.VersionString);Conso......
  • Python format()格式化输出方法详解
    前面章节介绍了如何使用%操作符对各种类型的数据进行格式化输出,这是早期 Python 提供的方法。自Python2.6版本开始,字符串类型(str)提供了 format()方法对字符串进行......
  • SpringBoot环境属性占位符解析和类型转换
    转自:https://www.cnblogs.com/throwable/p/9417827.html前提前面写过一篇关于Environment属性加载的源码分析和扩展,里面提到属性的占位符解析和类型转换是相对复杂的,这篇......
  • SpringBoot松散绑定(宽松绑定)@ConfigurationProperties
    配置绑定SpringBoot提供注解@ConfigurationProperties实现从配置文件自动注入对应的配置值到对应的Bean对象。认识松散绑定看下面的ServerConfig类的属性IPAddrEss和配......