情境:
路由器代码:
Router router = Router.router(vertx);
router.route().handler(BodyHandler.create());
router.route("/api/login/account").handler((RoutingContext ctx) -> {
// Handler is here
});
router.route("/api/currentUser").handler(ctx -> {
// Handler is here
});
router.route().handler(StaticHandler.create());
router.route("/*").hanler(StaticHandler.create("webroot/index.html"));
文件夹webroot包含以下文件:
问题:
我错过了哪里?什么是解决方案?
答案 0 :(得分:2)
您应该添加最后一个处理程序,以便在一切都失败时发送您想要的文件。例如:
ctx.response().sendFile('webroot/index.html');
不要忘记添加您可能需要的标头,例如缓存指令,位置,内容类型......