【问题标题】:Send two params in GET request在 GET 请求中发送两个参数
【发布时间】:2015-09-17 18:41:24
【问题描述】:

我是使用 vertx 框架的新手,在文档中我看不到关于如何在 GET 请求中发送两个参数的愚蠢事情。到目前为止,我已经尝试过了。

    $.getJSON('/user/'+ attributeName + ":"+value, function (data) {
    userListData = data;
    $.each(data, function () {
        $('#userInfoName').text(data.fullname);
        $('#userInfoAge').text(data.age);
        $('#userInfoGender').text(data.gender);
        $('#userInfoLocation').text(data.location);
    });
});

然后在服务器端

     router.get("/user/:attributeName:value").handler(routingContext -> {
        JsonObject query = new JsonObject();
        query.put(routingContext.request().getParam("attributeName"), routingContext.request().getParam("value")); 

然后我可以看到attributeName 不仅获得了第一个参数的值,而且还获得了第二个参数的一部分,非常奇怪。

【问题讨论】:

    标签: vert.x


    【解决方案1】:

    你可能做错了。您可以将其作为单个参数获取,然后使用“:”拆分,或者在 url 中定义两个参数为... /:attribname/:value/... 两者都会满足您的要求

    【讨论】:

      猜你喜欢
      • 2017-06-23
      • 1970-01-01
      • 2021-05-23
      • 1970-01-01
      • 2018-04-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多