2019年12月2日 | Leave a comment 问题: 解决: @io.quarkus.vertx.web.Route(path = "/book", methods = HttpMethod.GET) public void han3(RoutingContext rc) { var eng = io.vertx.ext.web.templ.thymeleaf.ThymeleafTemplateEngine.create(rc.vertx()); var resolver = new ClassLoaderTemplateResolver(); resolver.setPrefix("/templates/"); resolver.setSuffix(".html"); eng.getThymeleafTemplateEngine().setTemplateResolver(resolver); rc.put("msg", "你好哦i"); log.info("path: {}", rc.request().path()); var h = TemplateHandler.create(eng, rc.request().path(), "html"); h.handle(rc); } 123456789101112 @io.quarkus.vertx.web.Route(path = "/book", methods = HttpMethod.GET)public void han3(RoutingContext rc) { var eng = io.vertx.ext.web.templ.thymeleaf.ThymeleafTemplateEngine.create(rc.vertx()); var resolver = new ClassLoaderTemplateResolver(); resolver.setPrefix("/templates/"); resolver.setSuffix(".html"); eng.getThymeleafTemplateEngine().setTemplateResolver(resolver); rc.put("msg", "你好哦i"); log.info("path: {}", rc.request().path()); var h = TemplateHandler.create(eng, rc.request().path(), "html"); h.handle(rc);} pom.xml <dependencies> ..... <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-vertx-web</artifactId> </dependency> <!-- https://mvnrepository.com/artifact/org.thymeleaf/thymeleaf --> <dependency> <groupId>org.thymeleaf</groupId> <artifactId>thymeleaf</artifactId> <version>3.0.11.RELEASE</version> </dependency> <!-- https://mvnrepository.com/artifact/io.vertx/vertx-web --> <dependency> <groupId>io.vertx</groupId> <artifactId>vertx-web</artifactId> </dependency> <!-- https://mvnrepository.com/artifact/io.vertx/vertx-web-templ-thymeleaf --> <dependency> <groupId>io.vertx</groupId> <artifactId>vertx-web-templ-thymeleaf</artifactId> <version>3.8.3</version> </dependency> </dependencies> 123456789101112131415161718192021222324 <dependencies>..... <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-vertx-web</artifactId> </dependency> <!-- https://mvnrepository.com/artifact/org.thymeleaf/thymeleaf --> <dependency> <groupId>org.thymeleaf</groupId> <artifactId>thymeleaf</artifactId> <version>3.0.11.RELEASE</version> </dependency> <!-- https://mvnrepository.com/artifact/io.vertx/vertx-web --> <dependency> <groupId>io.vertx</groupId> <artifactId>vertx-web</artifactId> </dependency> <!-- https://mvnrepository.com/artifact/io.vertx/vertx-web-templ-thymeleaf --> <dependency> <groupId>io.vertx</groupId> <artifactId>vertx-web-templ-thymeleaf</artifactId> <version>3.8.3</version> </dependency> </dependencies>