MyException - 我的异常网
当前位置:我的异常网» Java Web开发 » jfreeChart路径有关问题

jfreeChart路径有关问题(2)

www.MyException.Cn  网友分享于:2013-01-20  浏览:123次

fileName=jfreechart-58472.png
url =/st2/DisplayChart?filename=jfreechart-58472.png
2010-9-27 14:24:17 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
警告: No configuration found for the specified action: '/jfreeChart2.jsp' in namespace: '/'. Form action defaulting to 'action' attribute's literal value.
2010-9-27 14:24:17 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
警告: Could not find action or result
There is no Action mapped for namespace / and action name DisplayChart. - [unknown location]
at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:178)
at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)
at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
at com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:47)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:478)
at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445)
at java.lang.Thread.run(Unknown Source)
我有点看不懂它的警告了,它说namespace的问题,可是页面中没有用到action啊,我的web.xml里是这样配置的
XML code

    <servlet>
        <servlet-name>DisplayChart</servlet-name>
        <servlet-class>
            org.jfree.chart.servlet.DisplayChart
        </servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>DisplayChart</servlet-name>
        <url-pattern>/DisplayChart</url-pattern>
    </servlet-mapping>



我的Tomcat的路径是D:\tomcat\Tomcat 6.0\temp
项目的路径是E:\myworkspace\st2\WebRoot
结果运行结果在网页上查看原代码的src是<img src="/st2/DisplayChart?filename=jfreechart-58472.png" width="500" height="300">

这是怎么回事啊,麻烦各位了

------解决方案--------------------
http://www.blogjava.net/hhhaaawwwkkk/archive/2010/03/31/317022.html
------解决方案--------------------
楼主不是只要控制图片路径吗 ?生成图片的方法网上一大把!贴一段网站上复制的代码
Java code

double[] data = {85, 156, 179.5, 211, 123};
  //The labels for the bar chart
  String[] labels = {"Mon", "Tue", "Wed", "Thu", "Fri"};
  
  DefaultCategoryDataset dataset = new DefaultCategoryDataset();
  for (int i = 0; i < data.length; i++) {
    dataset.addValue(data[i], null, labels[i]);
  }
  
  JFreeChart chart = ChartFactory.createBarChart3D("Weekly Server Load", "Work Week 25", "MBytes", dataset, PlotOrientation.VERTICAL, false, false, false);
  chart.setBackgroundPaint(new Color(0xE1E1E1));
  
  CategoryPlot plot = chart.getCategoryPlot();
  
  // 设置Y轴显示整数
  NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
  rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
  
  CategoryAxis domainAxis = plot.getDomainAxis();
  //设置距离图片左端距离
  domainAxis.setLowerMargin(0.05);
  
  BarRenderer3D renderer = new BarRenderer3D();
  //设置柱的颜色
  renderer.setSeriesPaint(0, new Color(0xff00));
  plot.setRenderer(renderer);
  
  //这里是保存图片到路径:默认是保存到tomcat的临时文件夹,你用我刚刚保存方法!
  //String filename = ServletUtilities.saveChartAsPNG(chart, 300, 280, null, session);

文章评论

软件开发程序错误异常ExceptionCopyright © 2009-2015 MyException 版权所有