我正在开发一个简单的标签库,以便集中创建表单组件。
在我的自定义标记中,我需要获取支持对象映射字段的值。
以下是我将字段名称值传递到我的库的方法:
<jsp:directive.attribute name="field" type="java.lang.String" required="true" rtexprvalue="true" description="The field exposed from the form backing object" />
在我的标签库中,使用 <form:hidden path="${field}.id" />
来自 spring 标签库的作品可以工作,但是我如何才能在不使用该库的情况下获得相同的值?我不想在表单中隐藏映射的输入类型,而只想检索该字段名称的值。
感谢您的任何提示。
最佳答案
您可以尝试 spring:eval 标签
<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]" />
关于java - 获取 jSTL 标签内属性的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24530719/