我正在尝试通过ResourceHandler
具有 RestEasy 部署的 Undertow 服务器中的 a 提供静态内容。
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 部署工作,我得到一个 404 的静态内容(index.html)。
任何指针?谢谢!