Reputation: 365
I want to get name of employee in a LinkedHashMap key from servlet to jsp.
I have this code in java class View.java
LinkedHashMap<Employee, LinkedHashMap<Skill, String>>() employeeSkills = new LinkedHashMap<Employee, LinkedHashMap<Skill, String>>();
Class View has setters and getters for employeeSkills.
Class Employee has name and id attributes with setters and getters.
JSP Code:
< c:forEach var="employeeSkills" items="${employeeSkills}" >
<td>${employeeSkills.key.name}</td>
</c:forEach>
but i get this error
javax.el.PropertyNotFoundException: Property 'name' not readable on type java.lang.String
Employee Class:
class Employee{
String id;
String name;
/**
* @return the id
*/
public String getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(String id) {
this.id = id;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
public Employee(String id, String name) {
super();
this.id = id;
this.name = name;
}
}
Upvotes: 1
Views: 2451
Reputation: 11579
Try this (call var
differently):
<c:forEach var="emplSkill" items="${employeeSkills}" >
<td>${emplSkill.key.name}</td>
</c:forEach>
Upvotes: 1