我正在使用spring 4
REST。
我有一个基础class
和许多其他class
扩展相同。例如,员工是基础class
,其他类 hr、工程师、培训师等扩展员工。
我必须创建REST API
以创建不同类型的员工。这interface
是一个POST
接受所有类型的员工。我不能interface
为每个子类型创建不同的。从基础上,我知道什么是子类型。
@RequestMapping(value= "/test/{employeeType}", method = RequestMethod.POST)
public void createEmp(@RequestBody Employee employee){
//If type is HR, I want to cast to HR type
//Is there any way we can take generic object in spring rest and then manage internally ?
}