public String doSearch(){
Map<String,Object> params = new HashMap();
params.put("page", page);
Object[] o =service.findAll(params);
page = new Page();
//Object[0]当前页的数据列表List,Object[1]总页数 ,Object[2]总记录数.
page.setList((List<Object>)o[0]);
page.setTotalCount(Integer.parseInt(String.valueOf(o[2])));
//到这的时候 page 对象当中就已经有值了 包括page下的list对象 ,和page下的totalcount对象
//list对像里放的 应该是查询出来的数据集合(内容) totalcount对象是总共的记录数(数量)
System.out.println("page中的List: "+page.getList().size()+"page中的totalpagecount: "+page.getTotalPageCount()+"page中的totalcount: "+page.getTotalCount());
return "success";
}
public static void main(String args[]){
HouseAction House = new HouseAction();
House.doSearch();
}
}
这个运行结果是
page中的List: 4page中的totalpagecount: 1page中的totalcount: 4
那也就是说page里面有信息的
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'house' 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>
<div class="main wrap">
<s:div id="houseArea">
<table class="house-list">
<s:if test="page==null || page.list==null ||page.list.size<1">
<tr>
<td colspan="11"><center>无任何信息</center></td>
</tr>
</s:if>
<s:else>
<s:iterator value="page.list" status="status">
<tr <s:if test="#status.count%2 == 0"> class="odd"</s:if>>
<td class="house-thumb">
<span>
<s:if test='picture.url!=null && picture.url !=""'>
<img src='<%=path+"/upload"%><s:property value="picture.url"/>' width="90" height="60" />
</s:if><s:else>
<img src="<%=path%>/img/thumb_house.gif" />
</s:else>
</span>
</td>
<td>
<dl>
<dt>pa
<s:a href="house!show.action?house.id=%{id}">
<s:property value="title"/>
</s:a>