开发者

<html:select> problem with <html:options> tag

I've a form with struts tags as below.

<html:form styleId='catform' action开发者_如何学JAVA='/cat/submit.html' method='post'>
   <html:select property='catName' styleId='catName'>
      <html:options collection='catList' property='category'>
   </html:select>
</html:form>

In my action I'm setting catList as below

 List <Category> catList = getCategoryList();
   request.setAttribute("catList", catList);

here Category is a class with catName and catId as variables.

I'm getting an error which says no getter for the property category found. What am I missing?


You need to put

<html:options collection='catList' property='catId' labelProperty='catName'>

struts is trying to get the category property of the Category instance


You need to put either a "collection", which is done between java tags like this :

collection="<%= myCollection %>"

or to use the "name" and "property" attributes like this :

name="mybean" property="beanPropertyWhichContainsTheCollection"

Don't use both "property" and "collection" attributes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜