Bean Validation 将 Object RequestParam 转换为@RequestBody
Bean Validation transforms Object RequestParam into @RequestBody
我有以下内容:
@PostMapping(produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<LoginResponse> getLoginStatus(@Valid LoginRequest loginRequest){
//some stuff here
}
loginRequest
参数是一个@RequestParam
,但是,因为是自定义对象,不需要对象前面的@RequestParam
注解。问题是当任何bean-validation注解放在自定义对象的前面时,对象被转换为body参数(@RequestBody
),但我们想要验证对象作为请求参数,而不是body参数。
有人能帮帮我吗?
LoginRequest
属性成为 RequestBody
而不是 RequestParameters
的一部分的原因是由于 springfox-swagger
版本 2.6.1。升级到版本 2.7.0 为我们解决了这个问题。
我有以下内容:
@PostMapping(produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<LoginResponse> getLoginStatus(@Valid LoginRequest loginRequest){
//some stuff here
}
loginRequest
参数是一个@RequestParam
,但是,因为是自定义对象,不需要对象前面的@RequestParam
注解。问题是当任何bean-validation注解放在自定义对象的前面时,对象被转换为body参数(@RequestBody
),但我们想要验证对象作为请求参数,而不是body参数。
有人能帮帮我吗?
LoginRequest
属性成为 RequestBody
而不是 RequestParameters
的一部分的原因是由于 springfox-swagger
版本 2.6.1。升级到版本 2.7.0 为我们解决了这个问题。