从会话 bean 评估 JSTL
我有一个提供 JSP 的 servlet,并且我正在尝试从会话 bean 的字符串中输出自定义标记。自定义标签无需评估即可打印出来。如果我将自定义标签添加到 JSP,它就像一个魅力,但我无法从会话 bean 动态添加它们。 我尝试过直接从会话 bean 输出:
<%= sessionBean.getTags() %>
并且
<% out.print(sessionBean.getTags()); %>
尝试创建一个接受字符串作为属性的自定义标记:
public class JSTLOut extends TagSupport {
String value;
public void setValue(String value) {
this.value = value;
}
public int doStartTag() {
try {
JSPWriter out = pageContext.getOut();
if (value != null) {
out.print.(value);
}
catch(IOException ioe) {
// TODO: handle
}
return(SKIP_BODY);
}
}
我尝试使用 Eval taglib
这个 taglib 导致了 LinkageError,显然与 websphere 配合不好。有人能指出我正确的方向吗?
I've got a servlet providing a JSP and I'm trying to output custom tags from a string from my session bean. The custom tags get printed out without being evaluated. If I add my custom tags to JSP it works like a charm but I cannot dynamically add them from the session bean.
I've tried the outputting straight from the session bean:
<%= sessionBean.getTags() %>
and
<% out.print(sessionBean.getTags()); %>
I've tried creating a custom tag that accepts a string as it's attribute:
public class JSTLOut extends TagSupport {
String value;
public void setValue(String value) {
this.value = value;
}
public int doStartTag() {
try {
JSPWriter out = pageContext.getOut();
if (value != null) {
out.print.(value);
}
catch(IOException ioe) {
// TODO: handle
}
return(SKIP_BODY);
}
}
I've tried using Eval taglib
This taglib caused a LinkageError, obviously not playing nice with websphere. Could anyone point me in the right direction?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定这是否会太乏味,但是您是否考虑过将自定义标签名称存储在查找数据库表中?然后,您可以在表中查询特定的自定义标记名称,并将任何自定义标记名称插入到需要从 servlet 返回的动态 JSP 中。
I'm not sure if this will be too tedious or not, but have you considered storing your custom tag names in a lookup database table? You could then query the table for a particular custom tag name and insert whatever custom tag name into the dynamic JSP that needs to be returned from the servlet.