T是代表什么呢?
/*
* Copyright (c) 2002-2007 by OpenSymphony
* All rights reserved.
*/
package com.opensymphony.xwork2;/**
* ModelDriven Actions provide a model object to be pushed onto the ValueStack
* in addition to the Action itself, allowing a FormBean type approach like Struts.
*
* @author Jason Carreira
*/
public interface ModelDriven<T> { /**
* Gets the model to be pushed onto the ValueStack instead of the Action itself.
*
* @return the model
*/
T getModel();}
/*
* Copyright (c) 2002-2007 by OpenSymphony
* All rights reserved.
*/
package com.opensymphony.xwork2;/**
* ModelDriven Actions provide a model object to be pushed onto the ValueStack
* in addition to the Action itself, allowing a FormBean type approach like Struts.
*
* @author Jason Carreira
*/
public interface ModelDriven<T> { /**
* Gets the model to be pushed onto the ValueStack instead of the Action itself.
*
* @return the model
*/
T getModel();}
泛型...,看看jdk1.5之后List等的用法List<?>,你说说的T和这里的?是相同的道理,你去看看Java反编译后的List类,和你的类似
interface MyGeneric<T>{
void setItem(T t);
T getItem();
}class A implements MyGeneric<String>{
String s=null;
public void setItem(String s){ //此处传入的参数只能是String或其继承类对象
this.s=s;
}
public String getItem(){ //此处返回的也只能是String类型对象
return s;
}
}class B implements MyGeneric<Integer>{
Integer s=null;
public void setItem(Integer s){ //此处传入的参数只能是Integer或其继承类对象
this.s=s;
}
public IntegergetItem(){ //此处返回的也只能是Integer类型对象
return s;
}
}