请问如何把jfreechar返回的chart在JSP页面中单独显示
枫中叶 2009-11-25 09:51:57 各位大侠:
请问如何把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;
}
}