我试图在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>
Run Code Online (Sandbox Code Playgroud)
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+"\"");
}
}
}
Run Code Online (Sandbox Code Playgroud)
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 …
Run Code Online (Sandbox Code Playgroud)