본문 바로가기
Spring/Problems

Failed to convert value of type 'java.lang.String' to required type 'java.util.Date'

by avvin 2019. 8. 19.


[Error]

Failed to convert value of type 'java.lang.String' to required type 'java.util.Date'


: Date 타입을 (jsp페이지에서) 파라미터로 받아올때



@RequestMapping(value="/fetch" , method=RequestMethod.GET)
    public @ResponseBody String fetchResult(@RequestParam("from") @DateTimeFormat(pattern="yyyy-MM-dd") Date fromDate) {
        //Content goes here
    }

Yes, it's simple. Just add the DateTimeFormat annotation.


출처 : https://stackoverflow.com/questions/15164864/how-to-accept-date-params-in-a-get-request-to-spring-mvc-controller