Results 1 to 6 of 6

Thread: Problem with javax.el.PropertyNotFoundException

  1. #1
    Join Date
    Aug 2008
    Posts
    3

    Default 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. #2
    Join Date
    Jan 2007
    Location
    Orlando, FL USA
    Posts
    84

    Default

    Have you tried adding "public" in front of your "myBean" class?
    http://www.jroller.com/thebugslayer - notes on java, scala and other development stuff.

  3. #3
    Join Date
    Aug 2008
    Posts
    3

    Wink RE: Problem with javax.el.PropertyNotFoundException

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

  4. #4
    Join Date
    Jan 2007
    Location
    Orlando, FL USA
    Posts
    84

    Default

    Wow! Calm down a bit there buddy.

    anyrate, glad u have things worked out
    http://www.jroller.com/thebugslayer - notes on java, scala and other development stuff.

  5. #5
    Join Date
    Oct 2007
    Posts
    4

    Default

    Thanks, bugslayer!

  6. #6
    Join Date
    Feb 2013
    Posts
    1

    Default Thank you buddy......

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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •