Hi!
When i try to access objects in an arraylist in the view page i get this exception:
javax.el.PropertyNotFoundException: Property 'name' not readable on type java.lang.String
myController.java
viewCode:public class myController extends AbstractController { protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception{ Map<String, Object> myModel = new HashMap<String, Object>(); List<testBean> testArray = new ArrayList<testBean>(); testArray.add(new myBean("Joakim","1")); testArray.add(new myBean("Nina","2")); testArray.add(new myBean("Henrik","3")); myModel.put("test",testArray); return new ModelAndView("view", "model", myModel); } } class myBean implements Serializable{ private String id; private String name; public myBean(String name, String id){ this.id=id; this.name=name; } public String getName(){ return name; } public void setName(String name){ this.name=name; } }
produces this exceptionCode:<c:forEach items="${model.test}" var="p"> ${p.name}<br/> </c:forEach>
javax.el.PropertyNotFoundException: Property 'name' not readable on type java.lang.String
Following code
produces following output:Code:<c:forEach items="${model.test}" var="p"> ${p.class.name}<br/> </c:forEach>
myBean
myBean
myBean
Have been wrestling with a while and i cant seem to figure it out.


Reply With Quote
