struts2中我定义了一个DepAction继承了BaseAction,表单提交到DepAction中无法把Dep这个对象封装到T中? 5
packagecn.itcast.action;importcn.itcast.service.IBaseService;publicclassBaseAction<T>...
package cn.itcast.action;
import cn.itcast.service.IBaseService;
public class BaseAction<T> {
private T t;
private IBaseService<T> baseService;
public IBaseService<T> getBaseService() {
return baseService;
}
public void setBaseService(IBaseService<T> baseService) {
this.baseService = baseService;
}
public T getT() {
return t;
}
public void setT(T t) {
this.t = t;
}
public void add(){
System.out.println(t);
}
}
package cn.itcast.action;
import cn.itcast.entity.Dep;
import cn.itcast.service.IDepService;
public class DepAction extends BaseAction<Dep> {
private IDepService depService;
public void setDepService(IDepService depService) {
this.depService = depService;
super.setBaseService(this.depService);
}
} 展开
import cn.itcast.service.IBaseService;
public class BaseAction<T> {
private T t;
private IBaseService<T> baseService;
public IBaseService<T> getBaseService() {
return baseService;
}
public void setBaseService(IBaseService<T> baseService) {
this.baseService = baseService;
}
public T getT() {
return t;
}
public void setT(T t) {
this.t = t;
}
public void add(){
System.out.println(t);
}
}
package cn.itcast.action;
import cn.itcast.entity.Dep;
import cn.itcast.service.IDepService;
public class DepAction extends BaseAction<Dep> {
private IDepService depService;
public void setDepService(IDepService depService) {
this.depService = depService;
super.setBaseService(this.depService);
}
} 展开
1个回答
展开全部
学过struts1没 struts2与struts1有一个区别是 struts2 帮用户封装了javaBean 而struts1没有想想是不是用struts2少些了很多代码啊,就是少了javaBean 当然还有其它的啦 struts2中的action 既是一个控制器也是一个javaBean action与页面没有什么关系 你要拿到action中字段值的话如下 <input id="name" value="${action中的属性}"> //用${}就可以拿到值
追问
我的意思是我表单提交的数据,无法封装到这个泛型类里,我想要抽取Action
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询