Vertx Web Routing基于本地化

时间:2018-03-23 08:02:14

标签: java routing localization vert.x

在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本地化路径?

1 个答案:

答案 0 :(得分:0)

实施将是这样的

        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...
        });