Announcement Announcement Module
Collapse
No announcement yet.
Can we use generic type in model? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Can we use generic type in model?

    calss GeneralModal<T extends BaseEntity>
    {
    private T entity
    public void setEntity(T entity)
    {
    this.entity=entity;
    }
    public T getEntity()
    {
    return entity;
    }
    }

    Now I have in my controller


    @Override
    @RequestMapping(value="", method=RequestMethod.POST)
    @ResponseBody
    public ModelAndView Filter(@ModelAttribute("entity") GeneralModal<RoleEntity> entity, BindingResult result, SessionStatus status) throws InstantiationException, IllegalAccessException
    {
    return super.Filter(entity, result, status);

    }


    Now before this method getting called it tries to fill
    @ModelAttribute("entity") GeneralModal<RoleEntity> entity
    where it gives error saying that
    Can't instantiate
    T entity
Working...
X