[英]How to create html tag in jsp page from java bean object
I'm trying to create jsp page that contains chart and tool tip on the chart. 我试图创建包含图表和图表上的工具提示的jsp页面。 I got to this point: I have a chart as image in my jsp page.
我到了这一点:我的jsp页面中有一个图表作为图像。 I have String that contians the html tag map with all the data about the tool tip.
我有String,它包含有关工具提示的所有数据的html标记映射。
I am looking for a way to take the String with all the data and put it in my jsp page as regular html tag. 我正在寻找一种方法来获取所有数据的String并将其作为常规html标签放在我的jsp页面中。
I tried to use : 我尝试使用:
<h:graphicImage id="linkGraph"
value="#{myBean.fileName}"
usemap="#{myBean.mapPath}"
width="#{myBean.width}"
height="#{myBean.height}"
rendered="true"
style="border-color: #ffffff;/>
#{myBean.mapHtml}
I'm getting it as text in my jsp page 我在jsp页面中将其作为文本获取
Thanks in advanced. 提前致谢。
Have you included the correct headers in your JSP, i,e: 您是否在JSP中包含正确的标头,即:
<%@page language="java" %>
<%@taglib prefix="h" uri="[taglib url]" %>
EDIT: 编辑:
To enable Expression Language: 启用表达语言:
<%@ page isELIgnored="false" %>
Then get your bean: 然后得到你的豆子:
<jsp:useBean id="myBean" class="fully.qualified.bean.class.MyBean"/>
And then use it in your tag: 然后在标签中使用它:
<h:graphicImage id="linkGraph"
value="${myBean.fileName}"
usemap="${myBean.mapPath}"
width="${myBean.width}"
height="${myBean.height}"
rendered="true"
style="border-color: #ffffff;/>
${myBean.mapHtml}
Note the ${byBean.property} expressions, with a $ not a #: your bean class needs matching getter methods, ie getFilename(), getMapPath() etc. 注意$ {byBean.property}表达式,带有$而不是#:您的bean类需要匹配的getter方法,即getFilename(),getMapPath()等。
I found a way to do it. 我找到了一种方法。 Create simple tag(div, span....) with id="tag" and with the help of java script function
使用id =“ tag”并借助Java脚本函数创建简单的tag(div,span ....)
function replaceString(str) {
document.getElementById("tag").innerHTML = str;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.