我试图在struts框架中禁用自动完成(自动完成=“关闭”),我遵循的过程是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");
}