本人公司项目做完了 要打包成.war文件 发布到tomcat中运行调试。发现导出数据到excel功能导出的数据全部为空 实际上是有数据的 仔细探究 发现了原因。
以前是用这种IO读取的方式来读取配置文件的。这种方式不可取。
Properties property = new Properties();
try {
String path = System.getProperty("user.dir"); //获取路径方法
path =path.replace("\\", "/");
String filePath = "/"+path+"/application.properties"; //得到Properties文件的目录
InputStream in = new FileInputStream(filePath);
property.load(in);
String value = (String)property.get(reportName);
现在换成 ResourceBundle rb = ResourceBundle.getBundle("application", Locale.getDefault());
String value= rb.getString(reportName); //获取键值ok 搞定。
本文介绍了解决从Web应用程序导出数据到Excel时数据为空的问题。通过更改配置文件读取方式,从使用Properties类转为使用ResourceBundle,成功实现了数据的正确导出。
292

被折叠的 条评论
为什么被折叠?



