如何在 struts 1 html taglib 中添加额外的 html 属性



如何在支柱 1 中将标准 html 属性添加到我的输入标签autocomplete="off"

我的输入:

<html:text property="appUser.username" size="21" maxlength="50"/>

javascript 解决方案不仅适合 CSS 或 struts 1 解决方案。

您可以添加覆盖 struts html taglib 的自定义 TLD。获取原始的struts-html.tld,将其复制为struts-html-autocomplete.tld在您的标签文件夹中。添加到表单标签

<tag>
    <name>form</name>
     ...
    <attribute>
        <name>autocomplete</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    ....
</tag>

在 web 中.xml定义新 TLD:

<jsp-config>
  <taglib>
    <taglib-uri>html</taglib-uri>
    <taglib-location>/WEB-INF/tags/struts-html-autocomplete.tld</taglib-location>
  </taglib>
</jsp-config>

最新更新