struts2中.<s:iterator value=>怎么在jsp页面没有显示,求解。求高手指点! 5
后台:实体类:packagecom.enty;publicclassUserIfo{privateStringusername;privateStringpassw;pu...
后台:
实体类:
package com.enty;
public class UserIfo {
private String username;
private String passw;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassw() {
return passw;
}
public void setPassw(String passw) {
this.passw = passw;
}
}
数据处理类:
public class GetDbInforn extends ActionSupport {
public List<UserIfo> list;//用户信息列表
public List<UserIfo> Infolist = new ArrayList<UserIfo>();
public List<UserIfo> getList() {
return list;
}
public void setList(List<UserIfo> list) {
this.list = list;
}
public String execute() {
Login_DbDao db=new Login_DbDao();
ResultSet rs;
try {
rs=db.query("select * from Table_1 ");
while(rs.next()){
UserIfo ifo=new UserIfo();
System.out.println(rs.getString("username"));
System.out.println(rs.getString("passw")+" ");
ifo.setUsername(rs.getString("username"));
ifo.setPassw(rs.getString("passw"));
Infolist.add(ifo);
}
this.setList(Infolist);
this.getList();
for(int i = 0 ; i< list.size();i++){
System.out.println(list);
}
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "visitor";
}
jsp页面
<s:iterator value="list" status="st">
<tr>
<td>
<s:property value="username" />
</td>
<td>
<s:property value="passw" />
</td>
</tr>
</s:iterator> 展开
实体类:
package com.enty;
public class UserIfo {
private String username;
private String passw;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassw() {
return passw;
}
public void setPassw(String passw) {
this.passw = passw;
}
}
数据处理类:
public class GetDbInforn extends ActionSupport {
public List<UserIfo> list;//用户信息列表
public List<UserIfo> Infolist = new ArrayList<UserIfo>();
public List<UserIfo> getList() {
return list;
}
public void setList(List<UserIfo> list) {
this.list = list;
}
public String execute() {
Login_DbDao db=new Login_DbDao();
ResultSet rs;
try {
rs=db.query("select * from Table_1 ");
while(rs.next()){
UserIfo ifo=new UserIfo();
System.out.println(rs.getString("username"));
System.out.println(rs.getString("passw")+" ");
ifo.setUsername(rs.getString("username"));
ifo.setPassw(rs.getString("passw"));
Infolist.add(ifo);
}
this.setList(Infolist);
this.getList();
for(int i = 0 ; i< list.size();i++){
System.out.println(list);
}
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "visitor";
}
jsp页面
<s:iterator value="list" status="st">
<tr>
<td>
<s:property value="username" />
</td>
<td>
<s:property value="passw" />
</td>
</tr>
</s:iterator> 展开
3个回答
展开全部
public List<UserIfo> list;//用户信息列表
public List<UserIfo> Infolist = new ArrayList<UserIfo>();
public List<UserIfo> getList() {
return list;
}
public void setList(List<UserIfo> list) {
this.list = list;
}
Infolist.add(ifo);
//设值是设到Infolist,页面取值是取list,list没有被赋值,所以没有数据!
//修改如下:
public List<UserIfo> Infolist;
public List<UserIfo> getInfolist() {
return Infolist;
}
public void setList(List<UserIfo> Infolist) {
this.Infolist= Infolist;
}Infolist.add(ifo);
<s:iterator value="Infolist" status="st">
//或者:
public List<UserIfo> list;
public List<UserIfo> getList() {
return Infolist;
}
public void setList(List<UserIfo> list) {
this.Infolist= list;
}
list.add(ifo);
<s:iterator value="list" status="st">
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
调试方法<s:debug>调试</s:debug>,先看看 那里面的值是否传过来了 ,看看页面是否有值
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<s:iterator value="list" status="st" var=listinfo> <tr> <td> <s:property value="#listinfo.username" /> </td> <td> <s:property value="#listinfo.passw" /> </td> </tr>
</s:iterator>
</s:iterator>
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询