Displaying JFreeChart in a web page using Struts2

前端 未结 3 1466
误落风尘
误落风尘 2021-01-24 11:31

I am using Struts2. I need to display JFreeChart in a web page. Can any body help me on that?

Edit: it is getting displayed in binary format.

public Stri         


        
3条回答
  •  [愿得一人]
    2021-01-24 12:14

    JSP/Struts2/whatever-MVC pages always ends up as HTML. To display images in HTML, you need the element or whatever MVC component you'd normally to use to render a HTML element. To locate an image, you need to let its src attribute point to a valid URL which returns the image. This can be a static or dynamic resource, the client doesn't see the difference.

    
    

    In a JSP/Servlet environment, the normal practice is to let a Servlet listen on the particular URL using url-pattern in web.xml such as /images/* and let it create/load/find the image based on request parameters or pathinfo and write the image to the outputstream of the response along a correct set of response headers.

    You can find a basic example here.

提交回复
热议问题