Spring 3 RadioButtonsTag Attribute 'items' must be an array, a Collection or a Map Exception

I am populate a List of String as radio button in the JSP. I add the List to the ModelMap but still the below Exception occurred. What am i missing please?

Attribute 'items' must be an array, a Collection or a Map: java.lang.IllegalArgumentException: Attribute 'items' must be an array, a Collection or a Map

@Controller public class EmployeeController { @Autowired private EmployeeManager employeeManager; @RequestMapping(value = {"/"}, method = RequestMethod.GET) public String homePage(ModelMap map) { map.addAttribute("employee", new Employee()); populateDepartments(map); return "addEmployee"; } private void populateDepartments(ModelMap map){ List<String> departments = new ArrayList<String>(); departments.add("Dept 1"); departments.add("Dept 2"); map.addAttribute("departments",departments); } }

addEmployee.jsp:

<form:form method="post" action="add" commandName="employee"> <table> <tr> <td><form:label path="name">Name</td> <td><form:input path="name" /></td> <td>Address</td> <td><form:input path="address" /></td> <td>Departments</td> <td><form:radiobuttons path="empDepartment" items="${departments}"/></td> </tr> <tr> <td colspan="2"> <input type="submit" value="Add"/> </td> </tr> </table> </form:form>

The entity

@Entity public class Employee { @Id @GeneratedValue(strategy=GenerationType.AUTO) private Integer id; private String name; private String address; @Transient private String empDepartment; }

Category:java Time:2018-12-25 Views:2

Related post

Copyright (C) pcaskme.com, All Rights Reserved.

processed in 0.460 (s). 13 q(s)