RT.
I want to verify that in the request InnerValidatedRequest, if the fields houseName and houseAddress, in the InnerValidatedRequestData member object are annotated with the @ Validated of SpringMVC, what else do you need to add?
if this is the case now, the two parameters will not be verified after a try.
-part of the code is as follows-
CommonController.java
@RestController
@RequestMapping(consumes = "application/json;charset=UTF-8", produces = "application/json;charset=UTF-8")
public class CommonController {
/**
* test for nested inner @Validated
* Exception
*/
@PostMapping("/inner/validated")
public String innerValidated(@RequestBody @Validated InnerValidatedRequest request) {
return "GOT!";
}
}
InnerValidatedRequest.java
@Getter
@Setter
public class InnerValidatedRequest extends BaseUserRequest {
private InnerValidatedRequestData reqData;
private String otherParma1;
private String otherParma2;
}
InnerValidatedRequestData.java
@Getter
@Setter
public class InnerValidatedRequestData implements BaseRequestData {
@NotBlank(message = "")
private String houseName;
@NotBlank(message = "")
private String houseAddress;
}
ask this question, mainly because there are many interfaces here to send http requests to the background system. If there is an object that can be directly turned into a sent request, it can reduce a lot of work. For example, I can send InnerValidatedRequestData directly as a request to the background system to get the data I want.