求struts中logic的使用方法及具体例子,谢谢

iamsoloist 2003-07-31 04:00:53
我主要是想通过它取bean里的东西,我看教程好象是通过iterate,但没看明白,请大家帮忙,谢谢大家
...全文
31 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
iamsoloist 2003-08-01
  • 打赏
  • 举报
回复
明白了,谢谢大家:)
kui 2003-07-31
  • 打赏
  • 举报
回复
logic标签主要有:
equal标签:<logic:equal parameter="" value="" >
</logic:equal>
forward标签:<logic:forward name="" />
greaterEqual标签:<logic:treaterEqual name="" property="" scope="page" value="" >
</logic:treaterEqual>
greaterThan标签:(下面我就不举例了,JSPStudio开发工具的Struts标签工具栏中提供了各种标签,拖动到JSP文件中就行了,上面就是“拖”出来的内容)
iterate标签:
lessEqual标签:
lessThan标签:
match标签:
notMatch标签:
notEqual标签:
notPresent标签:
present标签:
redirect标签:
flashroom 2003-07-31
  • 打赏
  • 举报
回复
属性 描述 collection 如果没有设置name属性,它就指定了要进行重复的集合 Id 页作用域bean和脚本变量的名称,它保存着集合中当前元素的句柄 indexed 页作用域JSP bean的名称,它包含着每次重复完成后集合的当前索引 Length 重复的最大次数 Name 作为集合的bean的名称,或是一个bean名称,它由property属性定义的属性,是个集合 Offset 重复开始位置的索引 property 作为集合的Bean属性的名称 Scope 如果指定了bean名称,这个属性设置bean的作用域。若没有设置,搜索范围从页到应用程序作用域 Type 为当前定义的页作用域bean的类型 例如: <logic:iterate id=”currentInt” collection=”<% =myList %>” type=”java.lang.Integer” offset=”1” length=”2”> <% =currentint %> </logic:iterate> 代码将从列表中的第一个元素开始重复两个元素并且能够让当前元素作为页作用域和java.lang.Integer类型的脚本变量来使用。也就是说,如果myList包含元素1,2,3,4等,代码将会打印1和2。
zhxx 2003-07-31
  • 打赏
  • 举报
回复
<logic:iterate id="MertActionForm" name="merlist">

<bean:write name="MerActionForm" property="mername"/>

action:
List l = ....;
httpServletRequest.setAttribute("merlist" ,l);


http://www.csdn.net/develop/Read_Article.asp?Id=18330
wllmmm 2003-07-31
  • 打赏
  • 举报
回复
我现在正在做这个东西,通过logic取bean的东西应该没啥东东吧。但我还真不知道你说的那个"iterate"是个什么东西?
关注!
关注
我就是靠这个文档实现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"%>









账务查询


基本信息查询。














基本信息查询。







<logic:iterate id="item" name="list" indexId="index">





logic:iterate>

帐号

帐户别名

是否为主帐户

">







这是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,512

社区成员

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

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