使用自定义标记时,jsp scriplet文本在jsp输出中显示为原样

使用自定义标记时,jsp scriplet文本在jsp输出中显示为原样,jsp,custom-tags,scriptlet,Jsp,Custom Tags,Scriptlet,我有两个自定义标记mbar.tag和mitem.tag,如下所示:- test.jsp mbar标记计算为一个元素 mitem标记计算为一个元素,其值为title作为元素的主体 它们在tld文件中声明 jsp的输出是 <html> <body> <% String sArg = request.getParameter("someparam"); %> <div> <div>images/**<%= sArg %>

我有两个自定义标记mbar.tag和mitem.tag,如下所示:- test.jsp


mbar标记计算为一个元素 mitem标记计算为一个元素,其值为title作为元素的主体 它们在tld文件中声明

jsp的输出是

<html>
<body>
<% String sArg = request.getParameter("someparam"); %>
<div>
    <div>images/**<%= sArg %>**-first.png</div>
    <div>images/**<%= sArg %>**-second.png</div>
</div>
</body>
</html>

images/***-first.png
图像/***-second.png
结果包含scriplet逐字记录,而我要求替换sArg的值。
屏幕上不会返回任何错误。看到jsp中支持jsp scriplets,我确信这与自定义标记有关。我缺少什么?

不要使用scriptlet。从未。为了避免使用scriptlet,引入了自定义标记和JSP EL

使用JSP EL:

<mytags:mitem title="images/${param.someparam}-first.png"/>

并确保标签的标题标签是,使用

true

在TLD文件的属性声明中。

当然,jee5 tut还说标记处理程序应该用于自定义标记,我只是在自定义标记中尝试scriplets。我尝试了你的解决方案,效果很好。谢谢
<mytags:mitem title="images/${param.someparam}-first.png"/>
<rtexprvalue>true</rtexprvalue>