jsp - How to get value of bean property when property name itself is a dynamic variable -
I am trying to write a custom JSPX tag that reads the value of the given property in a given list, With the name of property passed to the tag as JSP attribute The tag will look something like this:
& lt; Jsp: root xmlns: c = "http://java.sun.com/jsp/jstl/core" xmlns: jsp = "http: //java.sun.com/JSP/Page" version = "2.0" & gt; ; & Lt; Jsp: Output omit-xml-declaration = "yes" /> & Lt; Jsp: directive.attribute name = "item" type = "java.lang.Iterable" required = "true" description = "whose properties to read" rtexprvalue = "true" /> & Lt; Jsp: directive.attribute name = "propertyName" type = "java.lang.String" required = "correct" description = "bean property name to read" rtexprvalue = "true" /> & Lt; C: forEach item = "$ {items}" var = "item" & gt; & Lt ;! - It's a job that does not work - & gt; & Lt; Jsp: getProperty name = "item" property = "$ {propertyName}" /> & Lt; / C: foreach & gt; & Lt; / Jsp: root & gt;
The problem is that the property
attribute of jsp: getProperty
tag does not accept expression, only one verbatim value. So this will work, but there is no use for me (as I do not know the name of the property till runtime):
The error I get is:
org.apache.jasper.jasperException: org.apache.jasper.JasperException: PWC6054: Anyone on Thanks for any help you can not get the information. '<$ Code = "Post-Text" itemprop = "text"> If you want to use the dynamic property name, use the brace notation.
& lt; C: forEach items = "$ {items}" Var = "item" & gt; $ {Item [property name]} & lt; / C: forEach & gt;
Comments
Post a Comment