代码拉取完成,页面将自动刷新
一个简单、用于练手的使vertx-web支持 SpringMVC 风格的脚手架,或工具类。
直接通过接口启动即可。appClass 要在最顶层。
SimpleWebApplication.run(Vertx vertx, Class<?> appClass);
详细参考 test/WebApp.java
@HttpHandler(path = "/hi",contentType = "text/plain; charset=utf-8")
public String hi(@Param String msg){
return "hi " + msg;
}
@HttpHandler(path = "/home",contentType = "text/html;")
public String home(RoutingContext routingContext){
routingContext.put("msg","freemarker 中文");
return "home";
}
@HttpHandler(path = "/jsonobject")
public JsonObject jsonObject(){
return new JsonObject().put("now", LocalDateTime.now().toString())
.put("server","vertx")
.put("x","消息");
}
默认配置文件是 resources/http-server.json
只加了,
"templateEngine": "io.vertx.ext.web.templ.freemarker.FreeMarkerTemplateEngine"
这个自定义配置项,其他值参考vertx文档。
默认模板引擎是,freemarker。
其他配置项,参考vertx的 HttpServerOptions
编译的时候,记得加 -parameters。
只用于练手,或学习。
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。