问题描述:

We can validate input parameters via @Valid annotation before any param, like this:

@RestController // new spring 4 annotation

public class ApplicationServiceApiV1Controller {

@RequestMapping(value = "/response")

public SomeResponse getResponse(@Valid SampleInputParam request) {

return new SomeResponse();

}

}

SampleInputParam own fields can be annotated with any javax.validation.constraints.* annotation and those values will be validated. If validation fail, client receives 400 or 406 http status. Is it possible to validate response as described above? I didn't find that usages with spring-mvc.

相关阅读:
Top