到webRoot中写入文件 request对象有个获取当前web应用程序路径的方法,直接调用即可,具体忘记了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你需要传入参:pageContext上下文 public String getFilePath(String FilePath) { String RealPath = pageContext.getServletContext().getRealPath(FilePath); return RealPath; }PaintChartLable p = new PaintChartLable(); p.launchFrame(); ImageWriter writer = new JPGWriter(); String realpath=getFilePath(chartName + "Chart.jpg");writer.write(p,new FileOutputStream(realpath)); 主要是在java代码中实现找到webroot路径的需要的是classloader,得到的是classes路径再转换成你需要的路径就可以。经过一个网友指点,在这谢了他代码如下:String url = this.getClass().getClassLoader().getResource("").getPath();String path = url.replace("\WEB-INF", "");Path += "\\images\\";以上朋友说的是在jsp中拿到路径的办法。不过也谢了他们给我一些启发。 请教有关JS构造函数的相关知识疑难? 为什么js里面对样式的更改只在ie9上面有反应,在其他浏览器都没反应??? 仿amazon.com的菜单,有个缺陷,望高手补完 hide menubar,toolbar,addressbar in current window 动态建立的可编辑的iframe怎样对它的document添加onclick事件? Javascript失效 如何用JAVASCIRPT得到上个网页的网址(100分) 哪位提供一个这样的菜单例子 晕倒 如何让外部js脚本中的函数可以返回中文? 请问在一个PHP页面里直接写JS可以吗,新手 同一编辑器 提交后 处理的后台不同
public String getFilePath(String FilePath) {
String RealPath = pageContext.getServletContext().getRealPath(FilePath);
return RealPath;
}
PaintChartLable p = new PaintChartLable();
p.launchFrame();
ImageWriter writer = new JPGWriter();
String realpath=getFilePath(chartName + "Chart.jpg");
writer.write(p,new FileOutputStream(realpath));
需要的是classloader,得到的是classes路径
再转换成你需要的路径就可以。
经过一个网友指点,在这谢了他
代码如下:String url = this.getClass().getClassLoader().getResource("").getPath();
String path = url.replace("\WEB-INF", "");
Path += "\\images\\";以上朋友说的是在jsp中拿到路径的办法。不过也谢了他们给我一些启发。