[英]How do I serve static content with thorntail
I have a new project created using the Thorntail Project Generator .我有一个使用Thorntail Project Generator创建的新项目。 I want to serve a small amount of static files such as html, images etc
我想提供少量 static 文件,例如 html、图像等
How can I do this?我怎样才能做到这一点?
Assuming you build your project with Maven, you need to:假设您使用 Maven 构建项目,您需要:
<packaging>war</packaging>
<packaging>war</packaging>
io.thorntail:undertow
fractionio.thorntail:undertow
分数的依赖项src/main/webapp
(but not under src/main/webapp/WEB-INF
)src/main/webapp
(但不在src/main/webapp/WEB-INF
下)/
;/
; for example, if you use the most common way of enabling JAX-RS (creating an Application
subclass with the @ApplicationPath
annotation), make sure that you don't have @ApplicationPath("/")
, but something like @ApplicationPath("/api")
@ApplicationPath
注释创建Application
子类),请确保您没有@ApplicationPath("/")
,而是类似@ApplicationPath("/api")
I created a small example project here: https://github.com/rhoar-qe/thorntail-test-suite/tree/master/javaee/static-content我在这里创建了一个小示例项目: https://github.com/rhoar-qe/thorntail-test-suite/tree/master/javaee/static-content
Note that Thorntail is based on WildFly, and so includes the same servlet container: Undertow.请注意,Thorntail 基于 WildFly,因此包含相同的 servlet 容器:Undertow。 If you have more elaborate needs, you can find articles about serving static content with servlet in general and Undertow in particular everywhere on the web, including here on StackOverflow.
如果您有更详细的需求,您可以在 web 上找到有关使用 servlet 提供 static 内容的文章,尤其是在 Undertow 的任何地方,包括在 StackOverflow 上。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.