my code is like this
@PostMapping("/search/get_search_tips")
public String get_search_tips( @RequestParam("keywords") @NotNull String keyWords) {
return templateService.getSearchTips(keyWords).toJSONString();
}
Then when I miss the param keywords, it would return
{
"timestamp": "2023-02-01T10:09:16.283+00:00",
"status": 400,
"error": "Bad Request",
"path": "/template/search/get_search_tips"
}
I have written a handle to match @NotNull, when the code is
@PostMapping("/search/get_search_tips")
public String get_search_tips( @RequestParam("keywords",required = false) @NotNull String keyWords) {
return templateService.getSearchTips(keyWords).toJSONString();
}
Then when I miss the param keywords, it would return
{
"code": 1080,
"msg": "error param",
"result": [
{
"key": "keyWords",
"msg": "不能为null"
}
]
}
I need the rename param like keywords
match to keyWords
and want to get the second result, but I didn't want to write the code like
@RequestParam("keywords",required = false) @NotNull
What should I do?