jeecgboot / JeecgBoot

🔥「企业级低代码平台」前后端分离架构SpringBoot 2.x/3.x,SpringCloud,Ant Design&Vue3,Mybatis,Shiro,JWT。强大的代码生成器让前后端代码一键生成,无需写任何代码! 引领新的开发模式,引入AI模型能力 OnlineCoding->代码生成->手工MERGE,帮助Java项目解决70%重复工作,让开发更关注业务,既能快速提高效率,帮助公司节省成本,同时又不失灵活性。
http://www.jeecg.com
Apache License 2.0
40.7k stars 14.85k forks source link

列表页查询框(日期选择框)设置初始时间,一进入页面时,后台报日期转换类型错误的 #6631

Closed zxh866 closed 1 year ago

zxh866 commented 2 years ago
版本号:

jeecgboot-vue3 3.4.3

问题描述:

查询框(日期选择框)设置初始时间,一进入页面时,后台报日期转换类型错误的。点击查询按钮时,正常,没有这个问题。 另外:通过componentProps 的defaultValue设置默认值时,控件中可以显示默认值, 但是查询条件不起作用。

截图&代码:

前台代码: field: "revenueEndTime", component: 'DatePicker', componentProps: { showTime:false, valueFormat: 'YYYY-MM-DD', //defaultValue: '2022-11-30', }, defaultValue: '2022-11-30', colProps: {span: 6},

后台代码: @TableField(exist = false) @DateTimeFormat(pattern="yyyy-MM-dd") private Date revenueEndTime;

错误信息: 操作失败,org.springframework.validation.BeanPropertyBindingResult: 1 errors Field error in object 'financeRevenue' on field 'revenueEndTime': rejected value ["2022-11-29T16:00:00.000Z"]; codes [typeMismatch.financeRevenue.revenueEndTime,typeMismatch.revenueEndTime,typeMismatch.java.util.Date,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [financeRevenue.revenueEndTime,revenueEndTime]; arguments []; default message [revenueEndTime]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.util.Date' for property 'revenueEndTime'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [@org.springframework.format.annotation.DateTimeFormat java.util.Date] for value '"2022-11-29T16:00:00.000Z"'; nested exception is java.lang.IllegalArgumentException: Parse attempt failed for value ["2022-11-29T16:00:00.000Z"]]

友情提示(为了提高issue处理效率):

zhangdaiscott commented 2 years ago

你把完整的前端代码贴以下或者截图

zxh866 commented 2 years ago

你把完整的前端代码贴以下或者截图

1、data.ts中的查询数据 //查询数据 export const searchTotalFormSchema: FormSchema[] = [ { label: "收支开始时间", field: "revenueStartTime", component: 'DatePicker', componentProps: { showTime:false, valueFormat: 'YYYY-MM-DD', //defaultValue: '2022-11-03', //disabled: true, }, defaultValue: '2022-11-01', colProps: {span: 6}, }, { label: "收支结束时间", field: "revenueEndTime", component: 'DatePicker', componentProps: { showTime:false, valueFormat: 'YYYY-MM-DD', //defaultValue: '2022-11-30', }, defaultValue: '2022-11-30', colProps: {span: 6}, }, ];

2、Java实体类 /*删除标记/ //@Excel(name = "删除标记", width = 15) //@ApiModelProperty(value = "删除标记") @TableLogic private java.lang.String delFlag;

@TableField(exist = false)
@DateTimeFormat(pattern="yyyy-MM-dd")
private String revenueStartTime;

@TableField(exist = false)
@DateTimeFormat(pattern="yyyy-MM-dd")
private Date revenueEndTime;

@Excel(name = "金额", width = 15)
@TableField(exist = false)
private java.math.BigDecimal revenueAmount;

@Excel(name = "金额", width = 15)
@TableField(exist = false)
private java.math.BigDecimal expenditureAmount;

3、controller //@AutoLog(value = "财务收入支出-分页列表查询") @ApiOperation(value="财务收入支出-分页列表查询", notes="财务收入支出-分页列表查询") @GetMapping(value = "/getFinanceRevenueList") public Result<IPage> getFinanceRevenueList(FinanceRevenue financeRevenue, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, HttpServletRequest req) { //QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(financeRevenue, req.getParameterMap()); Page page = new Page(pageNo, pageSize); IPage pageList = page.setRecords(financeRevenueService.getFinanceRevenueList(page, financeRevenue)); return Result.OK(pageList); }

4、mapper文件

zhangdaiscott commented 1 year ago

ws

zhangdaiscott commented 1 year ago

已修复