在jsp中写java for_非常全面jsp页面的for循环示例程序

本文汇总了多种JSP页面中使用Java for循环的实例,包括不同场景的应用,无论你是初学者还是需要巩固循环知识,这篇文章都是很好的参考资料。
摘要由CSDN通过智能技术生成

本文章整理了很多的jsp 页面的for循环示例程序,如果你对于java循环不怎么了解不防进入参考一下,非常全面的一篇文章

例子1

 代码如下 复制代码

List  city=(List)request.getAttribute("list");

for(Object[] row:city){

%>

%>

后台list 代码

 代码如下 复制代码

public List getAllInfos() {

List list = new ArrayList();

// 配置sql代码

String sql = "select  CityInfo.cityInfoContent,TypeInfo.typeInfoName, CityInfo.cityInfoDataTime  from TypeInfo,CityInfo where CityInfo.typeInfoID=TypeInfo.typeInfoID";

Object[] obj = null;

Result result = cityInfoDao.runSelect(sql, obj);

if (result != null & result.getRowCount() > 0) {

Map[] maps = result.getRows();

for (Map row : maps) {

String cityInfoContent = row.get("cityInfoContent").toString();

String typeInfoName = row.get("typeInfoName").toString();

String cityInfoDataTime = row.get("cityInfoDataTime").toString();

Object[] objects = { cityInfoContent, typeInfoName, cityInfoDataTime };

list.add(objects);

}

}

return list;

}

例子2

 代码如下 复制代码

package com.zxd.test;

import java.util.List;

import org.hibernate.HibernateException;

import org.hibernate.Query;

import org.hibernate.Session;

import org.hibernate.SessionFactory;

import org.hibernate.cfg.Configuration;

import com.zxd.bean.House;

import com.zxd.util.QueryProperty;

/**

* HQL封闭查询的测试类

* @author zhang

*

*/

public class TestHouse {

public static void main(String[] args) {

//公共的成员变量

SessionFactory sf = null;

Session session = null;

QueryProperty qp = new QueryProperty();

//封装查询的数据

qp.setTitle("%好房%");

qp.setStreet_id("1002");

qp.setType_id("1004");

qp.setLow_price(20);

qp.setHigh_price(200);</

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值