对于分页参数page、count都做了@Min、@Max规定,参数传入违规参数系统并未报错,求解
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
@Validated
@RequestMapping("/v1/banner")
@RestController
public class BannerController {
@GetMapping("/page")
public void getBanners(@RequestParam(required = false, defaultValue = "0")
@Min(value = 0) Integer page,
@RequestParam(required = false, defaultValue = "10")
@Min(value = 1) @Max(value = 30) Integer count) {
/**
* 这里的@Max与@Min都失效了 Why?
*/
System.out.println(page);
System.out.println(count);
}
}
postman发送GET请求如下,最终得到状态码200正常,不晓得为什么