【问题标题】:How can I pass "type" attribute within <html:text> in struts1如何在 struts1 的 <html:text> 中传递“类型”属性
【发布时间】:2016-04-02 03:05:20
【问题描述】:

当我尝试在 struts1 中写这样的东西时:&lt;html:text styleId="Istituto" type="number"&gt; 它给了我一个错误

根据 TLD,标签文本的属性类型无效

如何将“type”属性添加到&lt;html:text&gt; 标签?

【问题讨论】:

  • 你不能。 html:text 是用于生成&lt;input type="text"&gt; 的标记。
  • 但是 不存在。在这种情况下,如何使用 jstl 输入类型号?
  • 你可以自己生成输入,或者创建一个相当于 html:text 的标签,或者意识到 Struts 1 是一个被官方废弃多年的项目,然后开始使用一些现代和维护的东西。
  • 规范的答案是修改 taglib 的 TLD 以接受动态属性。 IIRC Struts 1.3 已经这样做了,但我可能错了。

标签: jsp-tags struts-1


【解决方案1】:

感谢Milebza 的回答,但对我来说只有这种方法有效。

<input type="number" name="budgetValue" value="${applicantForm.budgetValue}" />

【讨论】:

    【解决方案2】:

    我知道这是旧的,但我目前正在开发一个使用 Struts 1 框架的超级旧应用程序,今天我遇到了同样的问题。这是我正在使用的有效解决方案:

    <input type="number" name="budgetValue" 
     value="<bean:write name="applicantForm" property="budgetValue"/>">
    

    在哪里: budgetValue - 是表单属性;申请人表格 - 是表格

    【讨论】:

    • 按预期工作。谢谢
    猜你喜欢
    • 1970-01-01
    • 2011-06-22
    • 1970-01-01
    • 1970-01-01
    • 2019-11-06
    • 2021-11-30
    • 2017-12-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多