Spring HTTP Status 400 - The request sent by the client was syntactically incorrect (when adding date input)

前端 未结 2 428
故里飘歌
故里飘歌 2021-01-07 12:46

When I add a date field on the jsp form I get this error, but it works fine without it.

Request

http://localhost:8080/myTasks/docrea         


        
2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-07 13:10

    A long time back I also faced this problem.

    I solved it using:

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

提交回复
热议问题