关于自定义标签当中的unable to find setter method for attribute:xxx错误 小记
来源:互联网 发布:paxos算法执行过程 编辑:程序博客网 时间:2024/05/16 09:11
这两天学习JSP的自定义标签内容 在调试的时候出现 unable to find setter method for attribute:xxx错误,
网上 看了各种解决方法:
总结尝试过的几点解决办法:
1)重写 getter和setter 方法 源代码定义如下:重新手写和利用myEclipse 给出 的getter和setter方法,均尝试过 仍然不起作用
package wex.tag;
import java.io.IOException;
import java.util.Properties;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
import javax.servlet.jsp.PageContext;
public class MessageTag extends TagSupport {
private String languageKey;
public synchronized String getLanguageKey() {
return languageKey;
}
public synchronized void setLanguageKey(String languageKey) {
this.languageKey = languageKey;
}
@Override
public int doEndTag() throws JspException {
// TODO Auto-generated method stub
Properties ps=(Properties)this.pageContext.getAttribute("ps", PageContext.APPLICATION_SCOPE);
try {
String message=(String)ps.get(languageKey);
pageContext.getOut().println(message);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return EVAL_PAGE;
}
}
2)严格按照java语言规范命名类和成员变量,发现问题依旧存在
3)最终发现致命点,是一个小的疏忽,原来是.tld文件里如下的定义出现问题,是定义<tag-class>的时候 自定义标签处理类 定义错了 ,定义到了另外一个文件 导致找不到setter方法,所以大家在写 自定义标签相关内容的时候 首先一定 按照‘java语言规范进书写,其次是一定要检查 .jsp文件和.tld文件 以及对应标签处理类的一致性 做到这两点,问题应该不会再出现!
<tag>
<name>message</name>
<tag-class>wex.tag.MessageTag</tag-class>
<body-content>empty</body-content>
<attribute>
<name>languageKey</name>
<required>true</required>
</attribute>
</tag>
写这篇日志 是为了记录这次小的错误 技术研发 需要严密的逻辑思维 !
- 关于自定义标签当中的unable to find setter method for attribute:xxx错误 小记
- 自定义标签 Unable to find setter method for attribute
- 解决使用Struts2的s:textfield标签出现Unable to find setter method for attribute: style的问题
- Unable to find setter method for attribute: [commandName]
- 关于Unable to find a 'userdata.img' file for ABI armeabi to copy into the AVD folder的错误
- [JPA错误]javax.persistence.EntityNotFoundException: Unable to find xxx
- [JPA错误]javax.persistence.EntityNotFoundException: Unable to find xxx
- 关于“Unable to find vcvarsall.bat”错误
- 自定义View XML文件出现No resource identifier found for attribute 'xxx' in package 'xxx.xxx.xxx'错误
- git 错误 fatal: Unable to find remote helper for 'https'
- git 错误: Unable to find remote helper for 'https'解决方法
- git 错误: Unable to find remote helper for 'https'解决方法
- 解决git的这个错误:fatal: Unable to find remote helper for 'https'
- 解决git的这个错误:fatal: Unable to find remote helper for 'https'
- Unable to find a result type for extension [...] in location attribute
- 错误:espliseappcompat_v7] ERROR: In <declare-styleable> MenuView, unable to find attribute android:pre
- Android 运行时错误 ConstraintSet, unable to find attribute android:elevation
- 自定义标签报错Unable to compile class for JSP
- HDU2542 矩形A + B
- HDU - 1312 Red and Black (dfs)
- A1080. Graduate Admission (30)
- python3使用ltp语言云
- jQuery 加载等待 转圈
- 关于自定义标签当中的unable to find setter method for attribute:xxx错误 小记
- 关于C++中的虚拟继承的一些总结
- Vim学习之一
- 英文文献中缩写的含义(i.e. i.i.d.)
- darknet 编译与使用
- 输入一组大于等于0的整数,根据从大到小的顺序排序后输出;如果排序后有连续数时,只输出连续输的最大和最小数。
- Python中的弧度转化以及三角函数
- 一个人的旅行
- 附两个自己认为比较重要的链接地址(移动端的position:fixed,flexbox实现垂直居中布局)