迭代获取不到值

Starry_H2m 2017-12-17 09:38:17
求大佬看看给个解答,jsp中不能迭代出来数据库中的数据,是不是Action中哪块xie'cuo'le
jsp内容:
<table width="800" border="1">
<s:iterator value="stuList">
<tr>
<td><s:property value="id"/> </td>
<td><s:property value="uname"/></td>
<td><s:property value="age"/></td>
<td><s:property value="className"/></td>
<td>
<a href="stuedit?stuid=<s:property value="id"/>">Edit</a>
<a href="studelete?stuid=<s:property value="id"/>">Delete</a>
</td>
</tr>
</s:iterator>
</table>
Action内容:
public class StudentAction extends ActionSupport{
private Student stu;
private List stuList=new ArrayList();
private String stuid;
// List<Student> stus = new ArrayList<Student>();
//Map request = (Map) ActionContext.getContext().get("request");
// request.put("stus",stus);
public Student getStu() {
return stu;
}
public void setStu(Student stu) {
this.stu = stu;
}
public String getStuId() {
return stuid;
}
public final List<Student> getList() {
return stuList;
}
public final void setList(List<Student> stus) {
this.stuList = stus;
}
public void setStuId(String stuid) {
this.stuid = stuid;
}

DBUtil db = new DBUtil();

public String list(){
ActionContext.getContext().put("stus", stuList);
try {
stuList = db.getAllStudent();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "list";
}

public String edit(){
try {
stu = db.getById(stuid);

} catch (Exception e) {
e.printStackTrace();
}
return "edit";
}

public String add(){

return "edit";
}

public String delete(){
try {
db.delete(stuid);
stuList = db.getAllStudent();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "list";
}

public String save(){
try{
if("".equals(stuid)){
db.insert(stu);
}
else{
db.update(stu, stuid);
}
stuList = db.getAllStudent();

}
catch (Exception e) {
// TODO: handle exception
}
return "list";
}
/*
public String execute() throws Exception
{
db.delete(stuid);
stuList = db.getAllStudent();

Map request = (Map) ActionContext.getContext().get("request");
//request.setAttribute("stus",stus);
request.put("stus", stuList);
return "list";
}*/
}
...全文
449 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧