简体   繁体   English

如何从Java bean对象在jsp页面中创建html标签

[英]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.

相关问题 从jsp页面上的select标签获取bean - Get bean from select tag on jsp page 如何将bean对象放入sessionMap,然后使用Struts 2属性标签在jsp页面上检索其属性 - How can I put a bean object to sessionMap, and then retrieve its properties on jsp page using Struts 2 property tag 如何在JSP中将标签属性值传递给Java Bean - How to Pass tag attribute value to Java Bean in JSP 如何在jsp页面的html标记中放入html标记 - How to put html tag inside html tag in jsp page 如何将字符串作为HTML代码从Java文件读取到JSP页面? - How to read a string as an HTML code from a Java file to a JSP page? 如何通过单击html页面中的菜单从jsp调用Java方法? - How to call a java method from jsp by clicking a menu in html page? JSP-如何创建从一个jsp页到另一个jsp页的链接 - JSP - how to create a link from a jsp page to another jsp page 如何使用从Java Bean到JSP页面的可变数据,反之亦然 - how to use variable data from java bean to jsp page and vice versa 如何将通过JSP页面中的JSTL定义的变量传递到Java bean中 - How to pass a variable defined through JSTL in JSP Page into Java bean Java,JSP-如何通过会话集属性将描述HTML标记的字符串传递给页面 - Java, JSP - How to pass a String describing an HTML Tag via session set attribute into page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM