struts select tag with values of a array list

后端 未结 2 1649
轻奢々
轻奢々 2020-12-02 02:31

I am developing a simple struts application. In my JSP I have a dropdown list box (using s:select tag). I need to fill the values with a arraylist values in the

相关标签:
2条回答
  • 2020-12-02 03:11

    Try to add get and set method for our field departmentlist,in your class Exple : in your class controller put this method for your field departmentlist :

    public  List<String> getDepartmentlist(){
      return this.departmentlist();
    }
    
    public void setDepartmentlist(List<String> departmentlist){
      return this.departmentlist = departmentlist;
    }
    
    0 讨论(0)
  • 2020-12-02 03:22

    The error

    "The requested list key 'departmentlist' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location] "

    means that the select tag is not able to resolve departmentlist as a collection. It is an OGNL expression which is trying to find the departmentlist in the value stack and if it not found or contains a null reference the select tag will complain. When you render the select tag make sure the list is in the value stack and is initialized. See the example here.

    0 讨论(0)
提交回复
热议问题