简体   繁体   中英

Get value of a property inside jstl tag

I'm developing a simple tag library in order to centralize the creation of form components.

In my custom tag I need to get the value of the backing object mapped field.

Here is how I pass the field name value to my library:

<jsp:directive.attribute name="field" type="java.lang.String" required="true" rtexprvalue="true" description="The field exposed from the form backing object" />

Inside my tag library, using <form:hidden path="${field}.id" /> from spring tag library works, but how can I get same value not using that library? I do not want to have an input type hidden mapped in my form, but only retrieve the value of that field name.

Thanks for any hints.

You can try the spring:eval tag

  <jsp:directive.attribute name="object" type="java.lang.Object" required="true" description="The form backing object" />
  <jsp:directive.attribute name="field" type="java.lang.String" required="true" description="The field name" />

  <spring:eval expression="object[field]" />

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM