我正在使用springboot创建rest服务。我写了一个post方法:
块引用
@RequestMapping(path = "/searchData", method = RequestMethod.POST,
consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<Collection<MySearchResult>> search(@Valid @RequestBody final MySearchCriteria criteria){
try {
//
}
}
我的搜索条件如下:
class MySearchCriteria{
private Date inputDate;
}
''''
When I pass json object like this:
{
"inputDate":"2020-12-35"
}
the code isn't throwing any error. It simply returns a date in february in the search criteria.
What do I need to validate whether the json string has a valid date or not?
暂无答案!
目前还没有任何答案,快来回答吧!