gpt4 book ai didi

java - Spring 中的自定义标签

转载 作者:行者123 更新时间:2023-12-01 13:36:03 25 4
gpt4 key购买 nike

我有自定义标签。它可以正常工作,但根本不起作用。我的 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com