logic:iterate 中的id与bean:write的name什么关系

hailun 2007-05-22 07:06:19
为什么我输入的内容会显示出来的呢?action里面并没有bean而只有session
如果我输入"uu"那么也应该是在vctor的这个Users里呀,跟这个id有什么关系呢

<logic:present name="Users">
<logic:iterate id="e" name="Users">
<bean:write name="e"/><br>
</logic:iterate>
</logic:present>

==================================================================
DynaActionForm addForm = (DynaActionForm) form;
String username = addForm.getString("username");
if (username == null || username.length() < 1)
mapping.getInputForward();
HttpSession session = request.getSession();
Vector users = (Vector) session.getAttribute("Users");
if (users == null)
users = new Vector();
users.addElement(username);
session.setAttribute("Users", users);
return mapping.findForward("indexGo");
...全文
301 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
hailun 2007-05-23
  • 打赏
  • 举报
回复
挺难理解的,呵呵
Miess 2007-05-23
  • 打赏
  • 举报
回复
就相当于起了个别名
mingr6370 2007-05-22
  • 打赏
  • 举报
回复
看做临时变量就好了
yanransoft 2007-05-22
  • 打赏
  • 举报
回复
对于vctor Users 中的每一个元素,它在迭代的时候叫做e。
for (Iterator iter = temp.iterator(); iter.hasNext();) {
Object e = (Object) iter.next();
}
就类似于java中的对象e。
我就是靠这个文档实现logic:iterate的循环的
struts 标签 logic:iterate使用 logic:iterate

第一页 是struts官方的说明,
第二页 是个例子
第三页 是我实现的arrayList放入标签的方法。
这是页面文件
<%@ page language="java"
import="java.util.*,cn.edu.bit.zgc2d.accountQuery.*" pageEncoding="GBK"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean"
prefix="bean"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html"
prefix="html"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic"
prefix="logic"%>









<%@ include file="../menu.txt"%>

idth=800>




idth=30>


账务查询


基本信息查询。

idth=800>



idth=700 bgcolor=gray colspan=2>

idth=800>




idth=30>


基本信息查询。







<logic:iterateid="item" name="list" indexId="index">





logic:iterate>
IDTH=100 bgcolor=#bfbfbf>
帐号
IDTH=100 bgcolor=#bfbfbf>
帐户别名
IDTH=100 bgcolor=#bfbfbf>
是否为主帐户
IDTH=100 bgcolor=F2F2F2>
"><bean:write name="item" property="account" />
IDTH=100 bgcolor=F2F2F2>
<bean:write name="item" property="other_name" />
IDTH=100 bgcolor=F2F2F2>
<bean:write name="item" property="is_main_account" />



这是action
public class InformationAction extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
InformationForm informationForm = (InformationForm) form;// TODO Auto-generated method stub
//业务开始
Connection conn = null; Statement st = null; ResultSet rs = null;
try {
db db = new db();
// 打开数据库
conn = db.conn();
// 创建st
st = conn.createStatement();
// 组织sql并执行
HttpSession session_account = request.getSession();
String account = (String) session_account.getAttribute("account");
String sql = "select * from account where main_account=" + account
+ "order by is_main_account desc";
rs = st.executeQuery(sql);
// 组建arrayList列表
ArrayList list = new ArrayList();
while (rs.next()) {
accountBean bean = new accountBean();
bean.setArea(rs.getString("area")); bean.setKind(rs.getInt("kind")); bean.setAccount(rs.getString("account")); bean.setMain_account(rs.getString("main_account")); bean.setType(rs.getInt("type")); bean.setOther_name(rs.getString("other_name")); bean.setPassword(rs.getString("password")); bean.setIs_main_account(rs.getInt("is_main_account")); bean.setMoney(rs.getString("money")); bean.setId(rs.getInt("id"));
list.add(bean);
}
HttpSession session = request.getSession();
session.setAttribute("list", list);
return mapping.findForward("success");
} catch (Exception e) { e.printStackTrace(); }
//业务结束
return null;
}
}//自己将需要的包导入
bean文件
package cn.edu.bit.zgc2d.accountQuery;

public class accountBean {
private String area;
private int kind;
private String account;
private String main_account;
private int type;
private String other_name;
private String password;
private int is_main_account;
private String money;
private int id;
public String getArea() {
return area;
}
public void setArea(String area) {
this.area = area;
}
public int getKind() {
return kind;
}
public void setKind(int kind) {
this.kind = kind;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public String getMain_account() {
return main_account;
}
public void setMain_account(String main_account) {
this.main_account = main_account;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public String getOther_name() {
return other_name;
}
public void setOther_name(String other_name) {
this.other_name = other_name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public int getIs_main_account() {
return is_main_account;
}
public void setIs_main_account(int is_main_account) {
this.is_main_account = is_main_account;
}
public String getMoney() {
return money;
}
public void setMoney(String money) {
this.money = money;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
}

67,542

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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