【发布时间】:2010-06-17 17:26:36
【问题描述】:
我想从会话 bean 中填充一个字段。
我试过这个:
`<html:text
property="docId"
value="<bean:write name="queryResponseBean" property="queryResults" />" />`
但无济于事。
谢谢。
【问题讨论】:
标签: html struts struts-html
我想从会话 bean 中填充一个字段。
我试过这个:
`<html:text
property="docId"
value="<bean:write name="queryResponseBean" property="queryResults" />" />`
但无济于事。
谢谢。
【问题讨论】:
标签: html struts struts-html
struts html:text 标记的“值”属性将除字符串或 RT Expr (scriplet) 之外,因此像上面使用的嵌套表达式将不起作用。相反,“queryResults”属性的值必须设置为 bean,然后使用脚本语言插入“value”属性。
它看起来像这样
<bean:define id="textVal" name="queryResponseBean" property="queryResults"/>
<html:text property="docId" value="<%=textVal%>"/>
【讨论】:
RT Expr 只允许在 struts html:text 标签的 value 属性中使用,因此避免使用嵌套表达式或 JSP 表达式语言。
【讨论】:
可以直接赋值,不要使用value=''属性:
html:text property="docId" property="queryResults" />
其中docId 必须是 BeanClass,而属性 (queryResults) 必须是 BeanClass 内的字段。
【讨论】:
尝试使用
<html:text
property="docId"
value="<bean:write name='${queryResponseBean}' property='queryResults' />" />
【讨论】: