项目中要生成pdf文件,PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStrea(D://ITextTest.pdf));window中可以指定到D盘,现在项目要发布到liunx中,不能直接给指定路径,该问题如何解决?
解决方案 »
- Caused by: org.hibernate.InvalidMappingException: Could not parse mapping docume
- java生成xml文档和解析xml文档,分别使用哪种技术比较好?
- java程序基础问题?
- struts2里关于文件下载一个问题
- -----------------ibatis取不到数据---------------
- 强制转换的问题
- successView isn't set 在spring中是个什么意思?
- ORACLE菜鸟一个,请各位前辈多多指导 那里有ORACLE的入门教程下载?请给个具体入门教程的网址. 有分回报谢谢!
- 用ejb统计数据库中的记录数时遇到的问题
- spring+springmvc+hibernate+oracle整合,测试不通,总报这个错
- HashMap缓存疑问
- 帮我解释一下数据库什么时候会加锁?!!!!!!!!
String rootPath = request.getSession().getServletContext().getRealPath("/");
Properties prop = System.getProperties();
String os = prop.getProperty("os.name");
if(os.toLowerCase().indexOf("windows") != -1){//windows
filePath = rootPath + "\\";
}else if(os.toLowerCase().equals("linux")){//Linux
filePath = rootPath + "/";
}
new FileOutputStrea(\usr\home\ITextTest.pdf)
lz意思應該是,路徑不能寫死。 最好是把路徑寫在配置檔中,
再寫方法來區分os,這樣日後改的code會非常少而方便。
判断os是windows还是linux就好了,这样取出的路径,跟os就没有关系了,移植之后,也就不用改code了。
String rootPath = request.getSession().getServletContext().getRealPath("/");
Properties prop = System.getProperties();
String os = prop.getProperty("os.name");
if(os.toLowerCase().indexOf("windows") != -1){//windows
filePath = rootPath + "\\";
}else if(os.toLowerCase().equals("linux")){//Linux
filePath = rootPath + "/";
}