gpt4 book ai didi

java - 如何使用 Thorntail 提供静态内容

转载 作者:行者123 更新时间:2023-12-02 09:24:00 25 4
gpt4 key购买 nike

我使用 Thorntail Project Generator 创建了一个新项目。我想提供少量静态文件,例如 html、图像等

我该怎么做?

最佳答案

假设您使用 Maven 构建项目,您需要:

  • 确保您的 Maven 项目是 <packaging>war</packaging>
  • 添加对 io.thorntail:undertow 的依赖项分数
  • 将您的静态内容放入 src/main/webapp (但不属于 src/main/webapp/WEB-INF )
  • 如果您还使用 JAX-RS,请确保 JAX-RS 应用程序未绑定(bind)到 / ;例如,如果您使用启用 JAX-RS 的最常见方法(使用 Application 注释创建 @ApplicationPath 子类),请确保您没有 @ApplicationPath("/") ,但类似于 @ApplicationPath("/api")

我在这里创建了一个小示例项目:https://github.com/rhoar-qe/thorntail-test-suite/tree/master/javaee/static-content

请注意,Thorntail 基于 WildFly,因此包含相同的 servlet 容器:Undertow。如果您有更详细的需求,您可以在网络上随处找到有关使用 servlet 提供静态内容(特别是 Undertow)的文章,包括 StackOverflow 上的此处。

关于java - 如何使用 Thorntail 提供静态内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58474451/

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