I was trying to display list of entities but I get this error:
javax.el.PropertyNotFoundException: Could not find property drug in class com.google.appengine.api.datastore.Entity
The way to display property is this:
<c:forEach items="${drugtargets}" var="drugtarget">
<tr>
<td>${drugtarget.drug}</td>
<td>${drugtarget.target}</td>
</tr>
I checked my datastore and entities properties and I didn't see any error. My properties are drug and target. Could you please tell me what I should do ? Thanks.
Key drugKey = KeyFactory.createKey("DrugTarget", drug);
Entity drugtarget = new Entity("DrugTarget",drugKey);
drugtarget.setProperty("drug", drug);
drugtarget.setProperty("target", target);
I don't do GAE, but according to the javadoc of that Entity
class, which tells that there's a getProperties()
method returning a Map<String, Object>
with all properties , then you should be able to access the individual properties as follows:
<td>${drugtarget.properties.drug}</td>
<td>${drugtarget.properties.target}</td>
Unrelated to the concrete problem, if this concerns user-controlled data, please keep in mind that this forms a potential XSS attack hole. You should be escaping user-controlled input using JSTL <c:out>
or fn:escapeXml()
.
<td><c:out value="${drugtarget.properties.drug}" /></td>
<td><c:out value="${drugtarget.properties.target}" /></td>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.