I have a new project created using the Thorntail Project Generator. I want to serve a small amount of static files such as html, images etc
How can I do this?
Assuming you build your project with Maven, you need to:
<packaging>war</packaging>
io.thorntail:undertow
fractionsrc/main/webapp
(but not under 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")
I created a small example project here: 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. 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.