Vertx基础

响应json, 需要安装jackson

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.13.4</version>
</dependency>

router
.get("/some/path")
// 这个处理器将保证这个Pojo会被序列化成json
// content type被设置成 "application/json"
.respond(
ctx -> Future.succeededFuture(new Pojo()));

或者
ctx.json(new Todo());

阅读更多