标签: query-parameters

encodeURIComponent 与 URLSearchParams 的不同输出

我使用URLSearchParmasAPI构建了一个带有查询参数的 oauth2 url 。但是,输出 URL 没有返回预期的 URL。任何人都可以帮助我理解这两个API之间的差异,我怎么能得到相同的结果的输出encodeURIComponent,使用URLSearchParams?谢谢!

const expected = encodeURIComponent('code id_token'); // code%20id_token

const search = new URLSearchParams();
search.set('response_type', 'code id_token');
search.toString(); // code+id_token
Run Code Online (Sandbox Code Playgroud)

url query-parameters oauth-2.0

6
推荐指数
1
解决办法
1288
查看次数

如何在NHibernate中将参数传递给IN运算符?

HI,

我正在尝试,为一个命名查询(本机sql)传递一个长数组,以便在IN STATEMENT中使用:像这样:

(...)WHERE Identificator IN(:pIdes)

我尝试传递我的ides []:

 ctx.GetNamedQuery("NamedQueryName")                                          
                   .SetParameter<long[]>("pIdes", Identificators)
                   .List<EmpreendimentoInputReport>();
Run Code Online (Sandbox Code Playgroud)

并作为一个字符串

 ctx.GetNamedQuery("NamedQueryName")                                          
                   .SetParameter<string>("pIdes", Identificators)
                   .List<EmpreendimentoInputReport>();
Run Code Online (Sandbox Code Playgroud)

当参数是一个字符串返回什么都没有,whem是一个long []返回这个oracle错误:

"Oracle.DataAccess.Client.OracleException:ORA-00932:tipos de dados inconsistentes:esperava NUMBER obteve BINARY"

有人可以帮帮我吗?

c# oracle nhibernate query-parameters ora-00932

5
推荐指数
1
解决办法
4075
查看次数

如何使用Jersey将POJO序列化为查询参数

我一直在为我公司的不同服务创建多个小型Java RESTful客户端库.大多数时候,我无法在服务器端更改任何内容,我需要编写Jersey代码片段以与现有RESTful API进行交互.


上下文

据我所知,我一直在使用Jersey和Jackson来使用JSON:当我查询POJO时,我从JSON反序列化它,当我需要发送POJO时,我将它序列化为JSON体.到目前为止,这两种片段一直在为我做这个工作......

查询和反序列化

ClientResponse response = webResource
    .path("/path/to/resource")
    .queryParam("key", "value")
    .accept(Mediatype.APPLICATION_JSON)
    .get(ClientResponse.class);

// (...) Check response status code

MyClassPojo pojo = response.getEntity(MyClassPojo.class);
Run Code Online (Sandbox Code Playgroud)

序列化和发送

ClientResponse response = webResource
    .path("/path/to/resource")
    .type(Mediatype.APPLICATION_JSON_TYPE)
    .accept(Mediatype.APPLICATION_JSON)
    .post(ClientResponse.class, pojo)

// (...) Check response status code
Run Code Online (Sandbox Code Playgroud)

问题

我现在面临一个RESTful服务器,它不接受JSON主体发送我的POJO.似乎唯一有用的是使用查询参数.

例如,如果我想发送对象

public MyClassPojo {
    public int attr1;
    public String attr2;
}

MyClassPojo pojo = new MyClassPojo();
pojo.attr1 = 42;
pojo.attr2 = "Foo bar";
Run Code Online (Sandbox Code Playgroud)

我本来喜欢用JSON序列化它:

{
    "attr1": 42,
    "attr2": "Foo bar"
}
Run Code Online (Sandbox Code Playgroud)

但是这个特定的RESTful服务器期待查询参数:

?attr1=42&attr2=Foo+bar …
Run Code Online (Sandbox Code Playgroud)

java rest jersey pojo query-parameters

5
推荐指数
1
解决办法
4700
查看次数

使用CURL使用查询参数发出GET请求

我从控制台发出以下curl请求来测试我的一个REST API

curl -X GET "http://localhost/api/v1/user/search.json?search_model[first_name]=abc&auth_token=xyzf"
Run Code Online (Sandbox Code Playgroud)

但它失败了以下错误

curl: (3) [globbing] error: bad range specification after pos 58
Run Code Online (Sandbox Code Playgroud)

我用端口封装了,"因为&它用于在控制台中执行珍贵的命令.我还缺少什么?为什么我会收到此错误?

rest console curl ruby-on-rails query-parameters

5
推荐指数
1
解决办法
5622
查看次数

Google+信息分享链接未显示说明?

我正在使用分享链接Google+: https://plus.google.com/share?hl=fr&url=http%3A%2F%2Fmywebsite.com%2F

我想知道为什么我的描述标签没有显示在共享窗口上.我只看到图像,标题,URL但我找不到任何描述.

<meta content="website" property="og:type">
<meta content="Something great" property="og:title">
<meta content="http://mywebsite.com/" property="og:url">
<meta content="My description blaah." property="og:description">
<meta content="http://mywebsite.com/img/partage.png" property="og:image">

<meta content="Something great" itemprop="name">
<meta content="My description blaah." itemprop="description">
<meta content="http://mywebsite.com/img/partage.png" itemprop="image">
Run Code Online (Sandbox Code Playgroud)

php share google-api query-parameters google-plus

5
推荐指数
1
解决办法
4191
查看次数

如何构建需要特定URL查询参数的Laravel路由?

假设我有这样的网址:

  1. localhost/admin/users/ <---主管理员用户页面
  2. localhost/admin/users /?data = refresh <----从该页面发出的典型ajax请求

还有一个像这样的简单控制器:

class UsersController extends Controller {

     public function index()

         // call some services
         // return a view
     }

     public function dataRefresh {

         // call some services
         // return some JSON
     }
}
Run Code Online (Sandbox Code Playgroud)

这是我的routes.php我正在努力:

    Route::get('admin/users', array('as' => 'admin.users', 'uses' => 'Admin\Users\UsersController@index'));
    Route::get('admin/users????' , array('before' => 'ajax', 'as' => 'admin.users', 'uses' => 'Admin\Users\UsersController@dataRefresh'));
Run Code Online (Sandbox Code Playgroud)

我在第二个路径中可以做什么来要求URL查询参数 ?data ,并且还需要将其设置为 data=refresh我如何确保它不与其他路线冲突?

注意:我知道某些人可能不会将此视为"漂亮网址".我在适当的时候实现了漂亮的URL/slugs,但是我也认为在很多情况下查询参数更清晰更清晰(即让用户清楚地了解页面URL的哪一部分用于过滤数据) datagrid ...并确保用户可以删除参数而不会导致页面中断或丢失).谷歌自己以及许多其他声誉良好的网站都是这样做的.

注意:我已将ajax路由过滤器应用于第二个路由.我还设置了路由指向我的控制器中的dataRefresh方法.

这是我所拥有的.有任何想法吗?

php query-parameters laravel laravel-4 laravel-routing

5
推荐指数
1
解决办法
4041
查看次数

django查询参数与空格

我有一个URL,其中包含可能包含空格的查询参数.我知道它看起来很简单,但我的正则表达式对我不起作用.

这是我的URL模式定义:

url(
    r'^item_info_details_view/(?P<itemno>[\w \/&-]+)/$',
    'purchasing.views.item_info_details_view'),  
Run Code Online (Sandbox Code Playgroud)

itemno可以是FAX MODEM包含空格的短语.

但是,当我将这样的参数传递给它时,浏览器中的URL就是

http://localhost/item_info_details_view/FAX%20MODEM/
Run Code Online (Sandbox Code Playgroud)

并显示此调试信息:

Using the URLconf defined in urls, Django tried these URL patterns, in this order:
^$
The current URL, item_info/FAX MODEM/, didn't match any of these.
Run Code Online (Sandbox Code Playgroud)

python django url query-parameters

5
推荐指数
1
解决办法
565
查看次数

在Angular 4中,如何将FormGroup转换为带有查询参数的URL?

在我的Angular应用程序中,我有一个多字段反应性表单,用户可以使用它来搜索我们的内部数据库。

当用户单击“搜索”时,我想转到SearchResultsComponent以显示结果。我还希望浏览器中的路由包含代表表单输入的查询参数,以便用户可以将其复制到某个位置并轻松地重复使用。本质上,按照我的想象,访问https://carsuniverse.com/?make=Honda&model=Civic&year=2009应该激活,SearchResultsComponent然后依次调用执行搜索的服务,将其返回给组件并显示在页面上

在Angular中这样做的最佳方法(至少是一种好方法)是什么?

query-parameters typescript angular-routing angular

5
推荐指数
1
解决办法
1040
查看次数

使用UriComponentsBuilder编码查询参数

我正在努力了解的行为UriComponentsBuilder。我想使用它在查询参数中对URL进行编码,但是它似乎只能转义%字符,而不可以转义其他必需的字符&

根本没有编码的查询参数中的URL的示例:

UriComponentsBuilder.fromUri("http://example.com/endpoint")
                    .queryParam("query", "/path?foo=foo&bar=bar")
                    .build();
Run Code Online (Sandbox Code Playgroud)

输出: http://example.com/endpoint?query=/path?foo=foo&bar=bar

这是不正确的,因为未编码的&原因bar=bar会被解释为/endpoint而不是的查询参数/path

但是,如果我使用包含%字符的输入::

UriComponentsBuilder.fromUri("http://example.com/endpoint")
                    .queryParam("query", "/path?foo=%20bar")
                    .build();
Run Code Online (Sandbox Code Playgroud)

输出: http://example.com/endpoint?query=/path?foo=%2520bar

%字符转义。

似乎UriComponentsBuilder会自动转义%字符,但不会自动转义其他保留字符,这是不一致的。

将URL编码为带有查询参数的正确过程是什么UriComponentsBuilder

java spring url-encoding query-parameters

5
推荐指数
1
解决办法
3307
查看次数

Angular 5全局查询参数

我想为应用程序的每个路径添加一个全局查询参数(类似于/ my/path?config = foo).我不想使用perserve query params选项,因为它保留了所有查询参数,我只想保留这个特定的查询参数.

我的应用程序使用不同的配置运行,可以由运行它的用户选择.此选项当前保存在配置服务中,并在关闭或重新加载选项卡/窗口时消失.我无法在本地存储或会话中保存选择,因为可以在同一浏览器的多个选项卡中打开不同的配置(据我所知,本地存储通过浏览器的所有选项卡是全局的 - 如果是不是隐身模式或类似的).

但我希望我的用户可以选择复制当前网址并将其发送给其他人,他们获得与发送链接的用户完全相同的数据和配置.

因此,我想在用户选择配置设置后立即自动将"config"查询参数附加到应用程序的每个URL.

routing query-parameters angular

5
推荐指数
1
解决办法
517
查看次数