action中的list在jsp中为空,为什么?
写了一个action类自己在action类中system.out.println打印出list的size为3,我在相应的jsp转发页面中却无法遍历,
不罗嗦上代码
这是action类
package com.actions;import java.util.List;import javax.annotation.Resource;import com.dao.interfaceImp.BasicUserDaoImp;import com.xu.model.BasicUser;public class showAllUsers { private BasicUserDaoImp budi; private List<BasicUser> bus; public BasicUserDaoImp getBudi() { return budi; } @Resource(name="BasicUserDaoImp") public void setBudi(BasicUserDaoImp budi) { this.budi = budi; } public List<BasicUser> getBus() { return bus; } public void setBus(List<BasicUser> bus) { this.bus = bus; } public String execute(){ try{ List<BasicUser> bus = budi.findAllBasicUser(); return "success"; } catch (Exception e){ e.printStackTrace(); return "input"; } }}
<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%><%@ taglib prefix="s" uri="/struts-tags" %><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <base href="<%=basePath%>"> <title>My JSP 'showAllBasicUser.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> <table> <s:iterator value="bus" id="bs"> <tr> <td> <s:property value="bs.id"/> </td> <td> <s:property value="bs.username"/> </td> <td> <s:property value="bs.branchBankName"/> </td> </tr> </s:iterator> </table> <s:debug/> </body></html>
public String execute(){ try{ bus = budi.findAllBasicUser(); return "success"; } catch (Exception e){ e.printStackTrace(); return "input"; } }
[解决办法]
List<BasicUser> bus = budi.findAllBasicUser();
红色部分删掉就行了。
[解决办法]
+1 就是这个意思