SpringMvc接收⽇期参数
1.Controller⽅法通过@DateTimeFormat注解来接收参数
@RequestParam("startTime") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date startTime
2.设置InitBinder接收参数1
@InitBinder public void initBinderQuery(WebDataBinder binder) {
3.设置InitBinder接收参数2
传⼊值?query.startTime=2020-04-23
@InitBinder("query")
public void initBinderQuery(WebDataBinder binder) {
}
4. 在参数接收实体上注解
springmvc的注解有哪些
直接在属性上加@DateTimeFormat注解,就可以进⾏转化⽇期格式
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date creatDate ;
public Date getCreatDate() {
return creatDate;
}
public void setCreatDate(Date creatDate) {
}
.