您的位置:首页 > 其它

通用BaseAction

2016-05-17 17:26 323 查看
package com.jzkj.career.action;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
/**
* 通用Action
* @author zhaoqx
*
*/
public class BaseAction<T> extends ActionSupport implements ModelDriven<T> {

protected T model;

public BaseAction() {
ParameterizedType type = (ParameterizedType) this.getClass().getGenericSuperclass();
Type[] types = type.getActualTypeArguments();
Class<T> clazz = (Class<T>) types[0];
try {
model = clazz.newInstance();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
public T getModel() {
return model;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: