public class AppServerAction extends BaseAction {
/**
*
*/
/**
* 初始化 “我的产品”列表 JSP页面,具有分页功能
*
* @param request
* @param model
* @return
*/
@Autowired
private StudentService stuservice;
private Map<String, Object> dataMap;//引文Map是接口,不能够new出接口对象,HashMap是类可以new出对象,这里要用到Map对象,但是不能直接用Map,所以要new一个HashMap子类
//
public String showStudent(){
dataMap=new HashMap<String, Object>();
int allAount=stuservice.getCount();//总条数
List<Student> stu=stuservice.selectPage(super.total,super.offset);
dataMap.put("total",stu.size());
dataMap.put("rows",stu);
return SUCCESS;
}
public StudentService getStuservice() {
return stuservice;
}
public void setStuservice(StudentService stuservice) {
this.stuservice = stuservice;
}
public Map<String, Object> getDataMap() {
return dataMap;
}
public void setDataMap(Map<String, Object> dataMap) {
this.dataMap = dataMap;
}
}
必须 在entity中加入toString()方法 才可以。
@Override
public String toString() {
return "Student [STU_ID=" + STU_ID + ", STU_NAME=" + STU_NAME
+ ", STU_AGE=" + STU_AGE + ", STU_SEX=" + STU_SEX + "]";
}
在实体中自动生成toString()方法,才可以将具体数据放入到datamap中。