出现前端传给后端日期提前一天的解决办法
3、前端对应日期选择框:value-format="YYYY-MM-DD"此项目是SpringBoot+vue3+elementplus。
·
此项目是SpringBoot+vue3+elementplus
1、application.yml
spring:
#设置jackson返回json数据时,时区和格式
jackson:
time-zone: GMT+8
date-format: yyyy-MM-dd
2、实体类对应属性
/**
*日期
*/
@DateTimeFormat(pattern="yyyy-MM-dd")
private Date occurdate;
3、前端对应日期选择框:value-format="YYYY-MM-DD"
<el-form-item prop="occurdate">
日期:
<!-- value-format="YYYY-MM-DD"-->
<!-- 解决前端传给后端的日期少一天-->
<el-date-picker
v-model="searchDate.occurdate"
type="date"
value-format="YYYY-MM-DD"
placeholder="请选择日期"
/>
</el-form-item>
4、前端的请求方法
doGet("/api/clinic/getRegister",
{
"patientname":this.searchDate.patientname,
//日期格式的参数,后端需要在实体类的日期字段上加一个注解
//@DateTimeFormat(pattern="yyyy-MM-dd")
"occurdate":this.searchDate.occurdate,
"currentPage":this.currentPage
}).then(resp=>{
if(resp.data.code===200){
console.log(resp)
this.Register=resp.data.data.list;
this.pageSize=resp.data.data.pageSize;
this.total=resp.data.data.total;
}
})
更多推荐
所有评论(0)