jsp如何获取struts2 action中返回的list中user的属性值?
我懂得action类:publicclassShowStuActionextendsActionSupport{privateIntegerbId;//用户ID,主键pr...
我懂得action类:
public class ShowStuAction extends ActionSupport {
private Integer bId;//用户ID,主键
private String stuId;//用户工号,主键
private String stuName;//用户名
private List stuList=new ArrayList();
public List getStuList() {
return stuList;
}
public void setStuList(List stuList) {
this.stuList = stuList;
}
public Integer getbId() {
return bId;
}
public void setbId(Integer bId) {
this.bId = bId;
}
public String getStuId() {
return stuId;
}
public void setStuId(String stuId) {
this.stuId = stuId;
}
public String getStuName() {
return stuName;
}
public void setStuName(String stuName) {
this.stuName = stuName;
}
public String execute() throws Exception
{
IStuDao stuDao=new StuDaoImpl();
stuList=(List) stuDao.findAll();
return SUCCESS;
}
}
然后我在jsp中:
<s:iterator var="stuList" status="st">
<tr>
<td><s:property value="bId" /></td>
<td><s:property value="stuId" /></td>
<td><s:property value="stuName" /></td>
</tr>
</s:iterator>
可就是获取不到,有谁知道原因么?寻求帮助啊! 展开
public class ShowStuAction extends ActionSupport {
private Integer bId;//用户ID,主键
private String stuId;//用户工号,主键
private String stuName;//用户名
private List stuList=new ArrayList();
public List getStuList() {
return stuList;
}
public void setStuList(List stuList) {
this.stuList = stuList;
}
public Integer getbId() {
return bId;
}
public void setbId(Integer bId) {
this.bId = bId;
}
public String getStuId() {
return stuId;
}
public void setStuId(String stuId) {
this.stuId = stuId;
}
public String getStuName() {
return stuName;
}
public void setStuName(String stuName) {
this.stuName = stuName;
}
public String execute() throws Exception
{
IStuDao stuDao=new StuDaoImpl();
stuList=(List) stuDao.findAll();
return SUCCESS;
}
}
然后我在jsp中:
<s:iterator var="stuList" status="st">
<tr>
<td><s:property value="bId" /></td>
<td><s:property value="stuId" /></td>
<td><s:property value="stuName" /></td>
</tr>
</s:iterator>
可就是获取不到,有谁知道原因么?寻求帮助啊! 展开
展开全部
request.setAtrribute("stuList",stuList); 你都没放租谨在作竖氏用域里弊纤基面怎么能取到啊
更多追问追答
追问
这个是struts2啊,不用这么放在作用域里吧?
追答
struts2N年前就用了
任何后台返回值都必须放在上下文,也就是request作用域,没有这些数据没办法上下传输,不用怀疑试一试即可。
public String execute() throws Exception
{
IStuDao stuDao=new StuDaoImpl();
stuList=(List) stuDao.findAll();
request.setAtrribute("stuList",stuList);
return SUCCESS;
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询