我有自定义标签。它可以正常工作,但根本不起作用。我的 jsp
看起来像:
<test:myTag>${headHunter.salary}</test:myTag>
其中 ${headHunter.salary}
是某个值。并标记:
public int doAfterBody() throws JspException {
String content = bodyContent.getString();
try {
JspWriter out = bodyContent.getEnclosingWriter();
out.print(content);
} catch (Exception e) {
}
return SKIP_BODY;
}
因此,如果 ${headHunter.salary}
等于 10
,标签必须返回相同的值。但它仅返回 "${headHunter.salary}"
作为字符串。怎么了?
UPD
taglib.tld:
<?xml version="1.0" encoding="UTF-8"?>
<taglib>
<tlibversion>1.0</tlibversion>
<shortname></shortname>
<jspversion>1.1</jspversion>
<tag>
<name>myTag</name>
<tagclass>net.babobka.blog.tags.CurrencyTag</tagclass>
<bodycontent>tagDependent</bodycontent>
</tag>
</taglib>
最佳答案
摆脱
<bodycontent>tagDependent</bodycontent>
它应该默认为无脚本
。 It seems tagDependent
prevents EL from being resolved 。
关于java - Spring 中的自定义标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21263795/