I have used javax validations for @RequestBody
and it works. say
public void putData(@Valid @RequestBody DataDTO dataDTO)
{
.....
}
class DataDTO
{
@Digit(integer = 10, fraction = 3)
private BigDecimal value;
}
But what if we do not have @RequestBody
or DTO
and just a single parameter. For example I have a following method in controller,
public String getCityWithTemprature(@RequestParam BigDecimal temptrature)
{
....
}
How I can validate it using @Digit
of javax validations Or any other best way to do it
Thank you :)
There is a Improvement filled in official spring jira. See this link to jira.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.