-
Generic type in model
I have Generic Type in modal
<code>
class BaseEntity
{
public int id;
}
class UserEntity extends BaseEntity
{
string name;
string password;
}
class RoleEntity extends BaseEntity
{
string description;
}
class GenericModal<T extends BaseEntity>
{
public T MyEntity; //has get and set methods
}
//now in
@Override
@RequestMapping(value="", method=RequestMethod.POST)
@ResponseBody
public ModelAndView Filter(@ModelAttribute("entity") GenericListModal<RoleEntity> entity, BindingResult result, SessionStatus status) throws InstantiationException, IllegalAccessException
{
return super.Filter(entity, result, status);
}
</code>
I can't get it worked. it gives error T can't instantiated.
Can any one give me any hint how to over come with this.
The same thing works perfectly in ASP.Net MVC