日期:2014-05-18  浏览次数:20726 次

hibernate+struts显示结果的问题(菜鸟级的)有方法马上结分
studentDAO里的stulist()方法:
        public   List   stulist()
        {      
        List   list=null;
        try
        {
        Session   session=HibernateSessionFactory.getSession();
        Transaction   tx=session.beginTransaction();
        Query   querylist=session.createQuery( "from   Student ");
        list=querylist.list();
        tx.commit();        
        }
        catch(HibernateException   e)
        {
              e.printStackTrace();
              tx.rollback();
        }
        finally
        {
        session.close();
        }
        return   list;
        }

showAction的execute方法内容:
StudentDAO   studao=new   StudentDAO();
List   list=(List)studao.stulist();
request.getSession().setAttribute( "list ",   list);
return   mapping.findForward( "/index.jsp ");
index.jsp迭代内容:
            <logic:iterate   id= "slist "   name= "lists ">
              <tr>
                  <td   width= "100 "   align= "center "> <bean:write   name= "slist "   property= "id "/> </td>
                  <td   width= "100 "   align= "center "> <bean:write   name= "slist "   property= "stuNo "/> </td>
                  <td   width= "100 "   align= "center "> <bean:write   name= "slist "   property= "stuName "/> </td>
                  <td   width= "100 "   align= "center "> change </td>
                  <td   width= "100 "   align= "center "> delete </td>
              </tr>
            </logic:iterate>

就是不显示数据。有异常Exception   forwarding   for   name   show:   javax.servlet.ServletException:   java.util.ArrayList

在控制台里有SQL语句执行:
select   student0_.ID   as   ID,   student0_.STU_NO   as   STU2_0_,   student0_.STU_NAME   as   STU3_0_   from   SYSTEM.STUDENT   student0_

高手帮忙     小弟急!!!解决马上给分。

------解决方案--------------------
网上的Hi