请问如何把jfreechar返回的chart在JSP页面中单独显示
各位大侠:
请问如何把jfreechar返回的chart在JSP页面中单独显示,因为jfreechar所返回的chart就是一个图形了,但我想让他在另一个JSP页面中来显示出来,不想让它用chart来显示,因为这样就会有一个问题,当我提交时,它显示的是chart图形了,而不能操作了,我想用另一个单独的JSP页面来获得chart,在jsp中显示形图,请各位大侠指点一下,我的代码如下:
这是struts.xml中的代码:
<!-- 饼图 -->
<action name="test" class="com.test.struts.TestAction">
<result name="success" type="chart">
<param name="height">500</param>
<param name="width">800</param>
</result>
</action>
以下是action中的代码:
public class TestAction extends ActionSupport {
public static Testdaoimpl testdaoimpl;
private JFreeChart chart;
public void setTestdaoimpl(Testdaoimpl testdaoimpl) {
this.testdaoimpl = testdaoimpl;
}
public JFreeChart getChart() {
Resource resource = new ClassPathResource("applicationContext.xml");
ListableBeanFactory bean = new XmlBeanFactory(resource);
testdaoimpl = (Testdaoimpl)bean.getBean("testdaoimpl");
List list = testdaoimpl.listTest();
DefaultPieDataset dpd = new DefaultPieDataset();
for(int i=0;i<list.size();i++)
{
Info info = (Info)list.get(i);
//以下是从数据库中得到的数据
dpd.setValue("管理人员",info.getNum());
dpd.setValue("市场人员", info.getAge());
dpd.setValue("其它人员", info.getPage());
}
JFreeChart chart = ChartFactory.createPieChart3D("某公司人员组织结构图", dpd, true,
true, false);
return chart;
}
@Override
public String execute() throws Exception
{
return SUCCESS;
}
}
请问如何把jfreechar返回的chart在JSP页面中单独显示,因为jfreechar所返回的chart就是一个图形了,但我想让他在另一个JSP页面中来显示出来,不想让它用chart来显示,因为这样就会有一个问题,当我提交时,它显示的是chart图形了,而不能操作了,我想用另一个单独的JSP页面来获得chart,在jsp中显示形图,请各位大侠指点一下,我的代码如下:
这是struts.xml中的代码:
<!-- 饼图 -->
<action name="test" class="com.test.struts.TestAction">
<result name="success" type="chart">
<param name="height">500</param>
<param name="width">800</param>
</result>
</action>
以下是action中的代码:
public class TestAction extends ActionSupport {
public static Testdaoimpl testdaoimpl;
private JFreeChart chart;
public void setTestdaoimpl(Testdaoimpl testdaoimpl) {
this.testdaoimpl = testdaoimpl;
}
public JFreeChart getChart() {
Resource resource = new ClassPathResource("applicationContext.xml");
ListableBeanFactory bean = new XmlBeanFactory(resource);
testdaoimpl = (Testdaoimpl)bean.getBean("testdaoimpl");
List list = testdaoimpl.listTest();
DefaultPieDataset dpd = new DefaultPieDataset();
for(int i=0;i<list.size();i++)
{
Info info = (Info)list.get(i);
//以下是从数据库中得到的数据
dpd.setValue("管理人员",info.getNum());
dpd.setValue("市场人员", info.getAge());
dpd.setValue("其它人员", info.getPage());
}
JFreeChart chart = ChartFactory.createPieChart3D("某公司人员组织结构图", dpd, true,
true, false);
return chart;
}
@Override
public String execute() throws Exception
{
return SUCCESS;
}
}
...全文
相关推荐
JfreeChar示例
- **返回响应**:Servlet 将图表作为图像流返回给 JSP,JSP 直接显示这个图像。
JFreeChar 压缩包
**chart.jsp**: 这是一个 JSP(JavaServer Pages)文件,表明可以使用 JFreeChart 在 Web 应用中创建动态图表,通过服务器端代码生成图表并显示在网页上。
jfreechar完整的例子
显示或保存图表:可以使用`ChartUtilities`类将图表写入文件,或者将图表添加到Java Swing组件中显示。
jfreechar的使用
#### 7.6 测试页面启动 Tomcat,访问 JSP 页面,可以看到图表显示在页面上。通过以上步骤,我们已经掌握了 JFreeChart 的基本使用。
一个jfreechar示例
**在JSP中显示:** 使用<img>标签引用这个动作,JSP页面将显示图表。


Web 开发
