【发布时间】:2018-06-14 16:56:33
【问题描述】:
在 Spring Web 响应式中为路径变量注册自定义反序列化器的正确方法是什么?
例子:
@GetMapping("test/{customType}")
public String test(@PathVariable CustomType customType) { ...
我尝试了 ObjectMapperBuilder、ObjectMapper 和直接通过 @JsonDeserialize(using = CustomTypeMapper.class) 但它不会注册:
Response status 500 with reason "Conversion not supported."; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert value of type 'java.lang.String' to required type '...CustomType'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.lang.String' to required type '...CustomType': no matching editors or conversion strategy found
【问题讨论】:
-
也许可以尝试提供Converter 和register it。
-
@JourneyCorner 你在用 Spring Boot 吗?
标签: java spring-webflux reactive