@RestController()
@RequestMapping(path = "/users")
public class UserController {
@GetMapping()
public @ResponseBody Page<User> getAllUsers(@RequestParam Integer pageSize, UserRequest userRequest) {
//TODO: some implementation
}}
public class UserRequest{
public String name;
public String age;
}
send the request with invalid parameter, like localhost:8800/users?
name1
=1234
, I want to return error. but in fact it ignore the invalid parameter name1.
I tried to add the user defined annotation on the method parameter and on the class , codes like below
@RestController()
@RequestMapping(path = "/users")
@Validated
public class UserController {
@GetMapping()
public @ResponseBody Page<User> getAllUsers(@RequestParam @Validated Integer pageSize, @Validated UserRequest userRequest} {
//TODO: some implementation
}
}
But it does not working.
I think it is happened because framework has ignore the invalid parameter before the method was called.
where did framework handle the url and how can I do to make it return error instead of ignore?