Use Springmvc annotation @DateTimeFormat to solve 400 invalid request problem

  • Add a comment above the field you want to convert
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm")     
private Date startTime;
  • Import maven joda-time dependencies for @DateTimeFormat using add configuration or manually add joda-time jar (especially important).

  • Spring-web add @DateTimeFormat using configuration add:

<mvc:annotation-driven></mvc:annotation-driven>

@DateTimeFormat realizes the Date conversion of the page passed to the control layer Controller, and will not affect other data queries.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325063892&siteId=291194637