java spring框架,控制层接收日期类型数据,出现403,接收不到等问题

xiaoxiao2025-04-21  16

总结的两个日期接收器 一 :前端传字符串类型日期 条件:只会接收到 指定类型 日期yyyy-MM-dd可以按自己想的 写

@InitBinder protected void initBinder(WebDataBinder binder) { binder.registerCustomEditor(Date.class, new CustomDateEditor(new SimpleDateFormat("yyyy-MM-dd"), true)); }

二:一股脑接收,不能确定到底接收的什么类型日期数据

@InitBinder protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) { // 处理Date类型 binder.registerCustomEditor(Date.class, new DateEditor()); binder.registerCustomEditor(String.class, new StringEditor()); }

如果前段是new Date()传的日期,应该是不需要接收器

转载请注明原文地址: https://www.6miu.com/read-5028800.html

最新回复(0)