Spring Boot—09通过Form提交的映射
package com.sample.smartmap.controller; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody; import com.sample.smartmap.controller.form.OrderPostForm;
import com.sample.smartmap.entity.User;
import com.sample.smartmap.service.UserService;
/**
* 通过form提交的各种映射举例
*
*/
@Controller
@RequestMapping("/javabean")
public class JavaBeanController { @Autowired UserService userService; @GetMapping(path = "/update.json")
@ResponseBody
public String updateUser(User user) {
System.out.println(user.getName());
System.out.println(user.getId());
return "success";
} @GetMapping(path = "/update2.json")
@ResponseBody
public String updateUser2(Integer id, String name) {
System.out.println(id);
System.out.println(name);
return "success";
} @GetMapping(path = "/update3.json")
@ResponseBody
public String updateUser3(@RequestParam(name="id",required=true) Integer id, String name) {
System.out.println(id);
System.out.println(name);
return "success";
} @PostMapping(path = "/saveOrder.json")
@ResponseBody
public String saveOrder( OrderPostForm form) {
return "success";
} @PostMapping(path = "/savejsonorder.json")
@ResponseBody
public String saveOrderByJson(@RequestBody User user) {
return user.getName();
} }
Spring Boot—09通过Form提交的映射的更多相关文章
- Spring Boot → 09:使用外置Servlet容器_tomcat9.0
Spring Boot → 09:使用外置Servlet容器_tomcat9.0
- 【spring boot】14.spring boot集成mybatis,注解方式OR映射文件方式AND pagehelper分页插件【Mybatis】pagehelper分页插件分页查询无效解决方法
spring boot集成mybatis,集成使用mybatis拖沓了好久,今天终于可以补起来了. 本篇源码中,同时使用了Spring data JPA 和 Mybatis两种方式. 在使用的过程中一 ...
- Spring Boot 如何防止重复提交?
Java技术栈 www.javastack.cn 优秀的Java技术公众号 在传统的web项目中,防止重复提交,通常做法是:后端生成一个唯一的提交令牌(uuid),并存储在服务端.页面提交请求携带这个 ...
- Spring Boot(三):RestTemplate提交表单数据的三种方法
http://blog.csdn.net/yiifaa/article/details/77939282 ********************************************** ...
- Spring boot 项目中put提交Date数据时出现type=Bad Request, status=400状态码
1.问题原因 经过测试发现,当客户端页面提交日期为空时会出现以下异常,如果提交日期不为空则不会出现上述问题.出现这种错误的原因是没有对代码中的Date型参数进行格式化,接收为null的日期类型参数时, ...
- Spring Boot 静态资源映射与上传文件路由配置
默认静态资源映射目录 默认映射路径 在平常的 web 开发中,避免不了需要访问静态资源,如常规的样式,JS,图片,上传文件等;Spring Boot 默认配置对静态资源映射提供了如下路径的映射 /st ...
- spring boot基础学习教程
Spring boot 标签(空格分隔): springboot HelloWorld 什么是spring boot Spring Boot是由Pivotal团队提供的全新框架,其设计目的是用来简化新 ...
- Spring Boot with Spring-Data-JPA学习案例
0x01 什么是Spring Boot? Spring Boot是用来简化Spring应用初始搭建以及开发过程的全新框架,被认为是Spring MVC的"接班人",和微服务紧密联系 ...
- Spring Boot中Web应用的统一异常处理 转载来自翟永超
我们在做Web应用的时候,请求处理过程中发生错误是非常常见的情况.Spring Boot提供了一个默认的映射:/error,当处理中抛出异常之后,会转到该请求中处理,并且该请求有一个全局的错误页面用来 ...
随机推荐
- linux,软链接配置node,npm全局命令
sudo ln -s /usr/local/bin/node /bin/node sudo ln -s /usr/local/bin/npm /bin/npm 这样配置后,在root下和别的 ...
- UIDevice currentDevice model possible values
NOTE: The below code may not contain all device's string, I'm with other guys are maintaining the sa ...
- C语言-apache mod(模块开发)-采用apxs开发实战(centos7.2 linux篇)
C语言-apache mod(模块开发)-采用apxs开发实战(centos7.2 linux篇) 名词解释:apxs apxs is a tool for building and installi ...
- 剑指offer三十二之把数组排成最小的数
一.题目 输入一个正整数数组,把数组里所有数字拼接起来排成一个数,打印能拼接出的所有数字中最小的一个.例如输入数组{3,32,321},则打印出这三个数字能排成的最小数字为321323. 二.思路 ( ...
- 关于JSON基础的总结
本文总结自百度百科 JSON 语法规则 JSON 语法是 JavaScript 对象表示语法的子集. 数据在键值对中 数据由逗号分隔 花括号保存对象 方括号保存数组 JSON 名称/值对 JSON 数 ...
- TCP与UDP的差别以及TCP三次握手、四次挥手
UDP: 1.UDP面向报文,无需建立连接,不可靠,数量小,高层就解决差错重传,无需拥塞控制 2.支持音频.视频传输 3.检查和检验UDP包头和数据和伪首部 4.分组开销小(头部8个字节),提供最大努 ...
- org.apache.hadoop.security.AccessControlException: org.apache.hadoop.security .AccessControlException: Permission denied: user=Administrator, access=WRITE, inode="hadoop": hadoop:supergroup:rwxr-xr-x
这时windows远程调试hadoop集群出现的这里 做个记录 我用改变系统变量的方法 修正了错误 网上搜索出来大概有三种: 1.在系统的环境变量或java JVM变量里面添加HADOOP_USE ...
- 【树】Lowest Common Ancestor of a Binary Tree(递归)
题目: Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. Accor ...
- C/C++ -- Gui编程 -- Qt库的使用 -- 信号与槽 -- 欢迎界面
程序运行先显示一个对话框,确定进入主程序 1.新建Qt工程,类MyWidget,基类QWidget 2.新建设计师界面类MyDialog,基类QDialog 3.-----main.cpp----- ...
- Dock的生态开源技术(Etcd&Machine&Compose&Swarm&Mesos&Kubernetes)
Etcd CoreOS公司开源的高可用分布式键值数据库Etcd,该项目已经被广泛应用到分布式系统的一致性实现和服务发现中,基于Go语言实现. Etcd就是专门为集群环境设计,可以很好地实现数据一致性, ...