0
我試圖在具有RestEasy部署的Undertow服務器中通過ResourceHandler
提供靜態內容。在UndertowJaxrsServer中爲靜態內容提供服務
public class Server {
public static void main(String[] args) throws Exception {
UndertowJaxrsServer server = new UndertowJaxrsServer();
Undertow.Builder serverBuilder = Undertow
.builder()
.addHttpListener(8080, "0.0.0.0")
.setHandler(
Handlers.path().addPrefixPath(
"/web",
new ResourceHandler(new PathResourceManager(Paths.get("/some/fixed/path"),100))
.setDirectoryListingEnabled(true)
.addWelcomeFiles("index.html")));
ResteasyDeployment deployment = new ResteasyDeployment();
deployment.setApplicationClass(MyRestApplication.class.getName());
DeploymentInfo deploymentInfo = server.undertowDeployment(deployment, "/")
.setClassLoader(Server.class.getClassLoader())
.setContextPath("/api").setDeploymentName("WS");
server.deploy(deploymentInfo);
server.start(serverBuilder);
}
}
通過上面的代碼,只有resteasy部署工作,我得到了靜態內容(index.html)的404。
任何指針?謝謝!