小编use*_*104的帖子

使用STRUTS禁用自动完成(autocomplete ="off")

我试图在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)

javascript jsp jstl custom-tags struts-1

5
推荐指数
1
解决办法
6118
查看次数

标签 统计

custom-tags ×1

javascript ×1

jsp ×1

jstl ×1

struts-1 ×1