Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows 错误Java.io.FileNotFoundException_Windows_Filenotfoundexception - Fatal编程技术网

Windows 错误Java.io.FileNotFoundException

Windows 错误Java.io.FileNotFoundException,windows,filenotfoundexception,Windows,Filenotfoundexception,在我的项目中,我阅读excel文件。这个功能在本地主机上工作,但我在服务器上上传这个项目时,我得到如下错误 java.io.FileNotFoundException: D:/Java_Question.xls (No such file or directory) at java.io.FileInputStream.open(Native Method) at java.io.FileInputStream.<init>(FileInputStream.java:146) at

在我的项目中,我阅读excel文件。这个功能在本地主机上工作,但我在服务器上上传这个项目时,我得到如下错误

java.io.FileNotFoundException: D:/Java_Question.xls (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:146)
at java.io.FileInputStream.<init>(FileInputStream.java:101)

因为您的项目在服务器上有不同的路径。 你应该像这样得到你的文件路径

String path = ServletContext.getRealPath("/FolderInYourProjectWhereExcelIsLocated");

@莱斯科弗。。我加上这个path@leskover我在上面添加了我的read excel文件代码,请检查它并告诉我在哪里添加字符串路径?我想知道如何从serverString path=ServletContext.getRealPath(“/FolderInYourProjectWhereExcelIsLocated”)实现read excel文件的代码的解决方案;我在哪里实现上述代码
String path = ServletContext.getRealPath("/FolderInYourProjectWhereExcelIsLocated");