有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java无法从资源加载文件,路径似乎错误

我得到了文件夹服务和webapp在同一级别上。 内部服务我有文件MailServiceImpl。JAVA 在里面我得到了这个:

@Override
public String getHTML() throws MalformedURLException, IOException {
    File initialFile = new File("../webapp/src/main/webapp/resources/html/Mail.html");
    InputStream targetStream = FileUtils.openInputStream(initialFile);
    String htmlFile = IOUtils.toString(targetStream);
    IOUtils.closeQuietly(targetStream);
    return htmlFile;
}

现在,在我的应用程序的部署版本中,路径似乎失败了。你知道如何使这条路相对吗? 路径在我的计算机上运行良好

以下是我的文件夹的外观:

enter image description here

enter image description here


共 (0) 个答案