在 vertx-web 中有什么简单的方法可以做到这一点吗?
en = 英文字符,cn = 简体字符,tw = 繁体字符
localhost:8080/en/home
localhost:8080/cn/home
localhost:8080/tw/home
localhost:8080/en/user/mange
localhost:8080/cn/user/mange
localhost:8080/tw/user/mange
有没有通用的方法来切换 en/cn/tw 本地化路径?
最佳答案
实现是这样的
Route route = router.route(HttpMethod.POST, "/:locale/home");
route.handler(routingContext -> {
String locale = routingContext.request().getParam("locale");
// Do something with them...
});
Route route = router.route(HttpMethod.POST, "/:locale/user/manage");
route.handler(routingContext -> {
String locale = routingContext.request().getParam("locale");
// Do something with them...
});
关于java - 基于本地化的 Vertx Web 路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49444937/