【发布时间】:2014-08-01 02:50:10
【问题描述】:
我试图在 struts 框架中禁用自动完成(autocomplete="off"),我遵循的过程是 1)在 Strut-html.tld 文件中,我几乎没有 TextTag 的属性,因此添加了自动完成属性
<tagclass>org.apache.struts.taglib.html.TextTag</tagclass>
<attribute>
<name>autocomplete</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
2)我通过扩展 org.apache.struts.taglib.html.TextTag 为 customtag 编写了一个类
import org.apache.struts.taglib.html.TextTag.*;
public class TextTag extends org.apache.struts.taglib.html.TextTag {
private static final long serialVersionUID = 1L;
private String autocomplete = null;
public String getAutocomplete()
{ return autocomplete; }
public void setAutoComplete(String autocomplete)
{
this.autocomplete = autocomplete;
}
protected void prepareOtherAttributes(StringBuffer sb) {
if (autocomplete != null) {
sb.append(" autocomplete=\""+autocomplete+"\"");
}
}
}
3) 在 jsp 页面中我添加了 autocomplete="off" 属性
所以当我运行我的应用程序时出现以下错误
/index.jsp(1): Error in using tag library uri='/tags/struts-html' prefix='html':
The Tagclass'org.apache.struts.taglib.html.FormTag' has no setter method corresponding
to TLD declared attribute 'name', (JSP 1.1 spec, 5.4.1) probably occurred due to an
error in /index.jsp line 1:
<%@ taglib uri="/tags/struts-html" prefix="html" %>
请有人帮我解决这个错误,我也尝试使用 javascript,但它不起作用。
function DisableAutocomplete()
{
var AC_Disable_login=document.forms[0].elements['loginID'];
AC_Disable_login.setAttribute ("autocomplete", "off");
}
【问题讨论】:
-
正确格式化代码。
-
嗨,Braj,我认为代码现在格式正确。
-
仍有一些对齐问题,但没有问题,它看起来比以前更好。
-
感谢您的链接,即使我以相同的方式尝试过,但它显示相同的错误。
标签: javascript jsp jstl struts-1 custom-tags