[英]Make object containing map property to querystring for Java @RequestParam
This is my class:这是我的 class:
@Getter
@Setter
public class Example {
private boolean taxFree;
private String email;
private Map<Enum,String> additionalConstraints;
}
This is my endpoint:这是我的端点:
@GetMapping(value = "/search", produces = MediaType.APPLICATION_JSON_VALUE)
public TransformedExample<Example> getPurchases(ExampleSearchQueryModel searchModel,
BindingResult result) {
if (result.hasErrors() || searchModel == null) {
LOGGER.error(result.getAllErrors().toString());
return null;
}
return exampleService.findByExampleSearchModel(searchModel);
}
If i have a class and endpoint like this how would my querystring have to look like so that spring can populate the map field "additionalConstraints"?如果我有一个 class 和这样的端点,我的查询字符串将如何显示,以便 spring 可以填充 map 字段“additionalConstraints”?
additionalConstraints.EMAIL=test or additionConstraints[EMAIL]=test additionalConstraints.EMAIL=test 或 additionConstraints[EMAIL]=test
always result in the map being mapped to null or a size(0) map.总是导致 map 被映射到 null 或 size(0) map。 How do i do this correctly?
我该如何正确地做到这一点?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.