I have a Spring Controller with this signature
public ResponseEntity<blabla> find(@RequestParam Long id, @RequestParam Long version, @RequestParam CheckedItemType type)
I am trying to make an http request with Jmeter setting the third parameter as: type=0 text/plain and I get a 400 error code cause the controller can't cast a String to CheckedItemType.
Any idea about how I can solve this?
Here, is an example:
public enum Modes {
ALPHA, BETA;
}
String to enum Converter:
public class StringToEnumConverter implements Converter<String, Modes> {
@Override
public Modes convert(String from) {
return Modes.valueOf(from);
}
}
Aregister our Converter:
@Configuration
public class WebConfig implements WebMvcConfigurer {
@Override
public void addFormatters(FormatterRegistry registry) {
registry.addConverter(new StringToEnumConverter());
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.