gpt4 book ai didi

java - SparkJava Web浏览器下载html文件而不是在部署war文件时显示

转载 作者:行者123 更新时间:2023-12-02 02:50:43 29 4
gpt4 key购买 nike

当我通过 Intellij 运行我的网络应用程序时,它工作正常。转到localhost:4567并且apache打开index.html页面。但是当我部署 war 文件并使用 java -jar project.war 运行它时,它会下载 index.html 页面

我的资源中有文件夹public。 index.html 就在那里


public static void main(String[] args) {
ProcessBuilder process = new ProcessBuilder();
Integer port;
if (process.environment().get("PORT") != null) {
port = Integer.parseInt(process.environment().get("PORT"));
} else {
port = 4567;
}

port(port);
staticFileLocation("/public");
}

我错过了什么?如果您需要任何其他信息,请在评论中告诉我

最佳答案

您应该使用2.7.2或更高版本,以前的版本有bug

关于java - SparkJava Web浏览器下载html文件而不是在部署war文件时显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57109926/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com