struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "red phoenix" <rodphoe...@gmail.com>
Subject struts2 <s:select> question
Date Sun, 02 Mar 2008 11:03:39 GMT
I use struts2.0.11, I use Hibernate to get data and put it into attribute in
struts2 action,like follows:
public String show() throws Exception{
  request=ServletActionContext.getRequest();
  List myList=this.getHibernateTemplate().find("from test.MyModel");
  request.setAttribute("myList",myList);
  return SUCCESS;
 }

Hibernate mapping file is follows:
<hibernate-mapping>
 <class name="test.MyModel" table="Test">
  <id name="id" column="id" type="java.lang.String">
   <generator class="assigned"/>
  </id>
  <property name="cname" type="java.lang.String">
   <column name="name" length="50" not-null="false" />
  </property>

Then I want to show myList by using <s:select> tag,like follows:
<s:select label="Myname" headerKey="-1" headerValue="choose"
list="%{myList}" listKey="MyModel.id" listValue="MyModel.cname" />

When I run it,it raise following error:
org.apache.jasper.JasperException: tag 'select', field 'list': The requested
list key '%{myList}' could not be resolved as a
collection/array/map/enumeration/iterator type. Example: people or
people.{name} - [unknown location]

I have searched google for several days,but I don't find how to solve it. I
am puzzled with it! I want to know how to correct my <s:select> code?
Any idea will be appreciated!
Best regards
Phoenix

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message