我正在尝试从war文件中读取.html文件。我使用了下面的代码,但它不起作用。
项目结构:
Project
|_war
|_Pages
|_HtmlFiles
|_sample.html
我的代码:
InputStream inputStream = EmailMessages.class.getClassLoader()
.getResourceAsStream("/sample.html");
答案 0 :(得分:1)
根文件夹位于类路径上,请尝试以下方法:
this.getClass().getResourceAsStream("/Pages/HtmlFiles/sample.html");
答案 1 :(得分:-1)
将文件放在void f( int (*fp)() )
{}
文件夹中,导出战争时,您可以在src\main\resources
目录下的resources
目录中找到您的文件。现在阅读像这样的html文件,
WEB-INF\classes