如何将数据库中存储在list中的对象取出在页面显示

在hibernate4.3.5+struts2.0中实现从数据库中读取数据存在list中,然后取出的时候就是显现不了
package lee;
import org.hibernate.Transaction;
import org.hibernate.Session;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;

import org.crazyit.app.domain.*;

public class HqlQuery
{
public static void main(String[] args)
throws Exception
{

    HqlQuery mgr = new HqlQuery();

mgr.findPersonProperty();
}

// 第三个查询方法:查询属性
public List<myBook> findPersonProperty()
{
    // 获得Hibernate Session
    Session sess = HibernateUtil.currentSession();
    // 开始事务
    Transaction tx = sess.beginTransaction();
    // 以HQL语句创建Query对象.
    List list = sess.createQuery("select  mb.bookAuthor,mb.bookName , mb.bookPrice,mb.image "
            + "from myBook mb").list();
        // Query调用list()方法访问查询得到的全部属性

    // 遍历查询的全部结果
    for (Object ele : list)
    {
        Object[] objs = (Object[])ele;
        System.out.println(java.util.Arrays.toString(objs));
    }
    // 提交事务
    tx.commit();
    HibernateUtil.closeSession();
    return list;
}

}
}

package org.crazyit.app.action;

import java.util.List;

import lee.HqlQuery;

import org.crazyit.app.domain.myBook;

import com.opensymphony.xwork2.ActionContext;

public class testAction {

public String execute() throws Exception
{
myBook mb=new myBook();
HqlQuery mgr = new HqlQuery();
List list=mgr.findPersonProperty();
ActionContext.getContext().put("list", list);
return "success";
}
}

<%@taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">



Insert title here


/s:debug
nameauthorpriceimage
${mb.bookName}${mb.bookAuthor}${mb.bookPrice}


题主前端页面没显示出来,

可以先看看下面这行代码中的list拿到内容没:

 ActionContext.getContext().put("list", list);

1、先打个断点看看List list=mgr.findPersonProperty()是否拿出了数据;
2、如果拿出了数据,可以打开浏览器的调试功能,看看传递到前台的值,使用el表达式可以拿出来

你的hibernate文件怎么配置的,详细说一下

应该是配置有问题

把你查询方法里面的事务干掉吧,你查询为什么要开启事务呢?

把list里面的对象转成map,页面循环list在用el表达式取

select mb.bookAuthor,mb.bookName , mb.bookPrice,mb.image "
+ "from myBook mb
改成这个试试
select new myBook(bookAuthor,bookName,bookPrice,image) from myBook