【问题标题】:Enter bean value into hidden input in Struts (1.x) with different name than bean将bean值输入到Struts(1.x)中的隐藏输入中,名称与bean不同
【发布时间】:2011-07-08 04:33:30
【问题描述】:

所以我有一个我正在使用的通用表单 bean,它有一些值,例如操作、报价、代码。

我正在开发一个使用此通用表单(必需)的新表单,但我想使用名称与我从中获取值的 bean 不同的 bean 的值来填充表单页面。

在第一次加载页面时,它会显示一些基本数据:

Action: (hidden input, name the same as the bean)
<html:hidden property="action"/>

Offer: (user input, name the same as the bean)
<html:text property="offer"/>

Code: (hidden input, name not the same as the bean)
<html:hidden property="code"/>

我要使用的 bean 是这样的:

<bean:write name="data" property="data.code.description"/>

如何将该值(data.code.desription)放入“隐藏”代码区域,以便在提交表单时通用表单 bean 获取该值?

【问题讨论】:

    标签: html jsp struts jsp-tags javabeans


    【解决方案1】:

    你可以这样尝试:

    <input type="hidden" name="code" value="<bean:write name="data" property="data.code.description"/>" />
    

    【讨论】:

      【解决方案2】:

      为什么不只是这个?

      <html:hidden property="data.code.description" name="scoreform_bean"/>
      

      参考javadocs for moreStruts html:hidden Tag

      【讨论】:

        猜你喜欢
        • 2012-08-10
        • 1970-01-01
        • 2012-05-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-03-22
        • 1970-01-01
        • 2018-08-07
        相关资源
        最近更新 更多