Announcement Announcement Module
Collapse
No announcement yet.
Problem with javax.el.PropertyNotFoundException Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with javax.el.PropertyNotFoundException

    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
    Code:
    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;
      }
    }
    view
    Code:
    <c:forEach items="${model.test}" var="p">
    	${p.name}<br/>
    </c:forEach>
    produces this exception
    javax.el.PropertyNotFoundException: Property 'name' not readable on type java.lang.String



    Following code
    Code:
    <c:forEach items="${model.test}" var="p">
    	${p.class.name}<br/>
    </c:forEach>
    produces following output:

    myBean
    myBean
    myBean



    Have been wrestling with a while and i cant seem to figure it out.

  • #2
    Have you tried adding "public" in front of your "myBean" class?

    Comment


    • #3
      RE: Problem with javax.el.PropertyNotFoundException

      I love you and i want to marry you right away!

      Comment


      • #4
        Wow! Calm down a bit there buddy.

        anyrate, glad u have things worked out

        Comment


        • #5
          Thanks, bugslayer!

          Comment


          • #6
            Thank you buddy......

            Its awesome yar.........thanks a lot.....

            Comment

            Working...
            X