需要的包:

struts2-jfreechart-plugin-2.2.1.1.jar

jfreechart-1.0.13.jar

jcommon-1.0.17.jar

前台jsp页面中可以使用iframe显示图表,代码

<iframe id="frm1" name="frm1"  src="/lzmgzyx/jfreechart.action" style="width:100%;height:700px"></iframe>

在struts.xml中配置,注意继承jfreechart-default,result的类型为chart

<package name="/lzmgzyx" extends="struts-default,jfreechart-default"
        namespace="/lzmgzyx">
        <action name="jfreechart" class="com.demo.jfreechart.JfreechartAction">
            <result name="success" type="chart">
               <param name="height">650</param>
               <param name="width">1300</param>
           </result>
        </action>
    </package>

action中要有chart全局变量,提供get、set方法

private JFreeChart chart;

前台提交请求后,aciton中的方法生成chart对象返回到前台就显示图表了。

action中方法例子

public String execute()
        {
                DefaultCategoryDataset dataset = new DefaultCategoryDataset();
                dataset.addValue(15, "第一个比较项", "第一项");
                dataset.addValue(25, "第一个比较项", "第二项");

                chart = ChartFactory.createBarChart3D("标题", "横轴", "纵轴", dataset,PlotOrientation.VERTICAL, true, true, true);
                configFont(chart);
                return SUCCESS;
        }

生成的图表

struts2整合jfreechart的更多相关文章

  1. struts2整合JFreechart 饼图、折线图、柱形图

    struts2整合JFreechart 饼图.折线图.柱形图 上效果图: 当然可以将数据导出图片格式存储.具体下的链接里的文件有保存成图片的操作. 因为是strust2整合JFreechart,所以s ...

  2. java项目中显示图表:struts2整合jfreechart

    需要的包: struts2-jfreechart-plugin-2.2.1.1.jar jfreechart-1.0.13.jar jcommon-1.0.17.jar 前台jsp页面中可以使用ifr ...

  3. 投票系统开发总结struts2,jfreechart,cookie应用,以及前端技术

    struts2配置web.xml+struts.xml: <?xml version="1.0" encoding="UTF-8"?> <we ...

  4. Spring与Struts2整合VS Spring与Spring MVC整合

    Spring与Struts2整合,struts.xml在src目录下 1.在web.xml配置监听器 web.xml <!-- 配置Spring的用于初始化ApplicationContext的 ...

  5. struts2整合spring的思路

    struts2整合spring有有两种策略: >sping容器负责管理控制器Action,并利用依赖注入为控制器注入业务逻辑组件. >利用spring的自动装配,Action将自动会从Sp ...

  6. struts2整合spring出现的Unable to instantiate Action异常

    在struts2整合spring的时候,完全一步步按照官方文档上去做的,最后发现出现 Unable to instantiate Action,网上一搜发现很多人和我一样的问题,配置什么都没有错误,就 ...

  7. struts2整合json要注意的问题

    昨天struts2整合json,一直出错: There is no Action mapped for namespace / and action name ... HTTP Status 404 ...

  8. struts2整合spring应用实例

    我们知道struts1与spring整合是靠org.springframework.web.struts.DelegatingActionProxy来实现的,以下通过具体一个用户登录实现来说明stru ...

  9. Spring4笔记12--SSH整合3--Spring与Struts2整合

    SSH 框架整合技术: 3. Spring与Struts2整合(对比SpringWeb): Spring 与 Struts2 整合的目的有两个: (1)在 Struts2 的 Action 中,即 V ...

随机推荐

  1. 如何更改 RSA 的语言设置

    国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html内部邀请码:C8E245J (不写邀请码,没有现金送)国内私 ...

  2. 在配置XML时报的The reference to entity "dataSource" must end with the ';' delimiter错误

    <?xml version="1.0" encoding="UTF-8"?> <ECharts> <element>http ...

  3. Ubuntu安装一:VM安装具体解释

    1.下载VM中文版:http://download.pchome.net/system/sysenhance/down-4673-1.html,解压后双击安装包: 2.点击:下一步 3.允许安装协议, ...

  4. Delphi 读取CPU Id

    在网上找了很久,终于找了一段能读出正确CPU ID 的代码,以下代码经过Delphi7测试 procedure TForm1.Button1Click(Sender: TObject); var _e ...

  5. RHCA学习笔记:RH442-Unit8进程与调度

      UNIT 8  Processes and the Scheduler 进程与调度 学习目标 A. CPU cache 与Service time之间的关系 B. 分析应用程序使用CPU cach ...

  6. iOS 推送,当接到推送消息时如何处理?

    接收到通知时有两种进入的方式:1.当app未运行时(BOOL)application:(UIApplication *)application didFinishLaunchingWithOption ...

  7. JS中checkbox组件的使用

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...

  8. winform中的Dock属性问题

    经过测试发现,winform中的Dock属性,先添加的控件,比后添加的控件的Dock权重要高.系统会优先显示先添加控件的Dock属性,再显示后添加的Dock属性. ------------------ ...

  9. textarea限制字符数

    html代码: <div class="remark_edit J_Remark_Edit"> <div class="tip-body"&g ...

  10. WebService 实现BS环境与BS环境传递参数,根据参数生成txt文档

    客户端: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Client.as ...