java - Accessing nested objects in JSP View -


i have list of objects. object of following class:

@entity @table(name="user") public class user {     @id     @column(name = "userid" ,unique=true, nullable=false)     private string id;     @column(name="firstname")     private string firstname;     @column(name="lastname")     private string lastname;     @column(name="title")     private string title;     @embedded     private address address;     @manytomany     @jointable(name="phone_user", joincolumns={@joincolumn(name="userid")},     inversejoincolumns={@joincolumn(name="phoneid")})     private list<phone> phones;      public string getid() {         return id;     }     public void setid(string id) {         this.id = id;     }      public string getfirstname() {         return firstname;     }     public void setfirstname(string firstname) {         this.firstname = firstname;     }      public string getlastname() {         return lastname;     }     public void setlastname(string lastname) {         this.lastname = lastname;     }     public string gettitle() {         return title;     }     public void settitle(string title) {         this.title = title;     }      public address getaddress() {         return address;     }     public void setaddress(address address) {         this.address = address;     }      public list<phone> getphones() {         return phones;     }     public void setphones(list<phone> phones) {         this.phones = phones;     }      } 

in controller method add list model as:

model.addattribute("lists",phone.getusers()); 

in jsp unable access lists getter methods. need access getid , getfirstname getters. jsp:

<c:foreach items="${lists}" var="listvalue">     <tr>         <td>employee id: <c:out value="${listvalue}"/></td>         <td>employee pass: <c:out value="${listvalue.getid()}"/></td>       </tr> </c:foreach> 

i following error:

org.apache.jasper.jasperexception: exception occurred processing jsp page /web-inf/views/phoneview.jsp @ line 33 

line 33 :

<td>employee pass: <c:out value="${listvalue.getid()}"/></td> 

i can't seem figure out problem is.

instead of invoking method getid() should use javabean style property:

<c:out value="${listvalue.id}"/> 

it should work because el (expression language) uses javabeans specification. in terms of specification listvalue java bean , id property read getter method getid().

see also: el wiki


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -