多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
前后端传递时间类型数据需要做如下处理: **1. 在时间类型的变量上标记注解`@DateTimeFormat`、`@JSONField`** ```java @Data public class Student { @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JSONField(format = "yyyy-MM-dd HH:mm:ss") private Date born; } ``` **2. controller层** ```java @Controller public class AsyncController { @ResponseBody @PostMapping(value = "/v2/async/student") public Student getMessage(Student student) { //Student(born=Thu Jun 02 20:14:30 CST 2022) System.out.println(student); return student; } } ``` **3. 前端传递时间** ```js $.ajax({ async: true, type: 'post', url: '${pageContext.request.contextPath}/v2/async/student', data: { 'born': '2022-06-02 20:14:30'}, dataType: 'json', beforeSend: function () { }, success: function (data) { console.log(data) //{born: '2022-06-02 20:14:30'} }, error: function (data) { } }) ```