前端date类型的数据,后端如何接收

2024-10-15 11:04:00

1、 @RequestMapping(value = "/add",method = RequestMethod.POST) @ResponseBody public Map<String,Object> add(Product product){ Map<String,Object> maps = new HashMap<String,Object>(); try { productService.save(product);

前端date类型的数据,后端如何接收

3、 @InitBinder public void initBinder(WebDataBinder binder){ DateFormat format = new SimpleDateFormat("yyyy-MM-dd"); binder.registerCustomEditor(Date.class, new CustomDateEditor(format,true)); }后端必须配置,springmvc 默认不会自动转换date

前端date类型的数据,后端如何接收

5、<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev"> <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span> <span class="sr-only">Previous</span> </a>

前端date类型的数据,后端如何接收

7、@RequestMapping(value = "/delete",method = RequestMethod.POST) @ResponseBody public Map<String,Object> delete( @RequestParam("ids[]") List<Long> ids){ Map<String,Object> result = new HashMap<>(); try{ for(Long i:ids){ productService.delete(i); } result.put("success",true); }catch (RuntimeException e){ e.printStackTrace(); result.put("success",false); result.put("errorInfo",e.getMessage()); } return result; }

前端date类型的数据,后端如何接收
猜你喜欢