![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
前后端联调
叹人间,美中不足今方信
这个作者很懒,什么都没留下…
展开
-
js构建form表单数据
背景后端接口:参数为Person,Person成员变量包含Other对象@RequestMapping("post")public Object post(Person person) { return JsonResult.success(person);}public class Person implements Serializable { private Other other; private String name; private Integer原创 2020-11-22 14:27:51 · 2144 阅读 · 1 评论 -
Spring mvc前后端数据交互(form表单和json数据)
ajax异步提交请求常用的contentType有两种:contentType:application/x-www-form-urlencoded contentType:application/json,如何使用springmvc处理请求数据呢?首先,我们来看一下js对象的两种数据格式:普通js对象,对象属性名不使用引号标注var baseJob = { jobName:...原创 2018-09-14 14:04:01 · 8575 阅读 · 1 评论 -
前后端联调之时间格式化(@DateTimeFormat/@JsonFormat)
前端提交时间字符串数据,后端使用@DateTimeFormat对于时间参数,前端可以传入long类型的时间戳,也可以传入字符串类型2019-03-15等类型。后端可以用String类型或者Date类型来接收字符串格式的时间参数,但是后端直接用Date类型接收参数,并且没有自定义的时间转换器,那么会抛出异常。此时,我们可以用spring提供的注解@DateTimeFormat来接收参数。// 类...原创 2019-03-15 15:46:13 · 6343 阅读 · 1 评论 -
前后端联调之Form表单提交数组
案例:后端以Form表单的Content-type形式接收Integer数组,接口和前端代码如下,前后端联调时,后端接收不到前端传递的参数接口: @ResponseBody @RequestMapping("/testIntegerArray") public Object o(Integer[] ids){ return "" } 前端: var ids = new Ar...原创 2019-01-14 19:02:29 · 6019 阅读 · 0 评论