Oh heck I misread your code there. This is Struts 1 and not Struts 2, isn't it? Sorry about that. jk
On Mon, Apr 20, 2009 at 12:08 PM, Jim Kiley <jhki...@summa-tech.com> wrote: > Have you tried writing a unit test to ensure that testList is populated > after your action executes? I'm pretty sure you'll find that it isn't. > It looks to me like you're declaring testList to be a local variable within > your action method (you're doing "List testList = " instead of "testList = > "). So your local testList goes out of scope as soon as the action method > is done executing. You need testList to be a field of your action, not a > local variable. > > jk > > > On Mon, Apr 20, 2009 at 12:01 PM, red phoenix <rodphoe...@gmail.com>wrote: > >> I have a table named mytable,it has two cols,col1 and col2,the data are >> col1 col2 >> --------------- >> John 24 >> Kate 18 >> >> hibernate xml file is follows: >> <hibernate-mapping auto-import="false"> >> <class name="mytable" table="mytable" > >> <id name="col1" column="col1" type="java.lang.String"> >> <generator class="assigned"/> >> </id> >> <property name="col2" type="java.lang.String"> >> <column name="col2" /> >> </property> >> </class> >> </hibernate-mapping> >> >> Then I user struts2 to get the data by following statement: List >> testList=this.getHibernateTemplate().find(" from mytable"); >> request.setAttribute("testList",testList); >> return SUCCESS; >> >> the action dispatch to following jsp page >> >> <table> >> <c:forEach var="test" items="${testList}"> >> <tr><td> >> <c:out value="${test.col1}"></c:out> >> <c:out value="${test.col2}"></c:out> >> </td></tr> >> </c:forEach> >> </table> >> >> Above codes run well,it can show correct result >> John 24 >> Kate 18 >> >> then I modify struts action,like following: >> List testList=this.getHibernateTemplate().find(" select col1,col2 from >> mytable"); >> request.setAttribute("testList",testList); >> return SUCCESS; >> >> the action dispatch to the same jsp,but this time,the jsp show nothing! >> Why? I don't understand what's wrong with my code? Anyone could help me to >> solve above problem? >> >> Thank >> > > > > -- > Jim Kiley > Senior Technical Consultant | Summa > [p] 412.258.3346 > http://www.summa-tech.com > -- Jim Kiley Senior Technical Consultant | Summa [p] 412.258.3346 http://www.summa-tech.com