转载自:http://zhidao.baidu.com/question/1637815200281856620.html?qbl=relate_question_0&word=baseAction
public T model ; @SuppressWarnings("unchecked") public BaseAction(){ try { ParameterizedType type = (ParameterizedType) this.getClass().getGenericSuperclass(); Class<T> clazz = (Class<T>) type.getActualTypeArguments()[0]; model = clazz.newInstance(); } catch (Exception e) { e.printStackTrace(); } }
貌似是获取BaseAction的父类对象的一个实例,并赋值给BaseAction的属性model 。