I have two classes Aand Bthat implement an interface.
public class A implements MyInterface {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
public class B implements MyInterface {
private MyCustomClass myCustomclass;
public String getName() {
this.myCustomclass.getName();
}
}
public interface MyInterface {
public String getName();
}
I want to use one controller method that can work on both A and B depending on which object the external interface sends. So when I try to use the interface, Spring complains that no suitable message converter was found.
@RequestMapping(value = "/mymethod", method = RequestMethod.POST)
public String updateRecord(@RequestBody MyInterface myInterface, HttpServletResponse response) {
}
source
share