所以,我发现了这个类似的请求,但发帖者回答了自己并详细说明了:
本质上,我有一个事件管理网站,我可以在其中编辑 html 和 javascript,但不能编辑 php。我正在尝试设置通过链接传递折扣代码以用于联属营销跟踪。系统已经允许代码以以下形式在查询中传递:
https://www.example.com/reg/newreg.php?eventid=89335&discountcode=code
但
需要注意的是,系统仅在将人员直接链接到注册过程时才允许这样做,如上所示。由于没有人想在没有看到活动详细信息的情况下购买门票,因此这几乎毫无用处。主页地址的形式为:
https://www.example.com/home/89335
但是,当我尝试将 &discountcode=code 附加到地址时,单击注册链接并转到注册页面后,查询字符串会丢失。
关于如何处理这个问题有什么建议吗?
谢谢!
我想通过 http 标头传递一个数组。
将多个参数命名为相同的名称是否可以接受,这样我就知道它们属于一个数组,就像在 get 请求查询字符串中一样?例子:
CurrentHeaderArray: myarray[]=value1&myarray[]=value2&myarray[]=value3
Run Code Online (Sandbox Code Playgroud)
已经有一个 stackoverflow 答案可以通过 get 请求的查询字符串传递它,请参阅此超链接。 如何在查询字符串中传递数组?
我想使用 spring 库UriComponentsBuilder生成以下路径: '/app#/fragment1?test=toto'。
到目前为止我已经尝试过:
UriComponentsBuilder ucb = UriComponentsBuilder.fromPath("/app").fragment("fragment1").queryParam("test","toto");
ucb.toUriString(); // -> gives me as result : '/app?test=toto#/fragment1'
Run Code Online (Sandbox Code Playgroud)
知道如何以优雅的方式实现这一点吗?
是否可以IS NOT在 http 查询字符串中执行 a 操作,以便将 IS NOT 作为 GET 请求中的运算符作为查询参数发送?
所以类似于:
api/v1/users?firstName!=John&lastName!=Doe
Run Code Online (Sandbox Code Playgroud) 我在一个类似的页面上http://example.com?query=value有一个表单<form id="formId" method="POST">。
http://example.com在没有查询字符串的情况下提交表单的最佳方式是什么?
我目前正在尝试:
$('#formId').submit(function(e){
e.preventDefault();
var url = window.location.href;
if (url.indexOf("?") != -1){
$('#formId').attr('action', url.split("?")[0]);
}
$('#formId').submit();
});
Run Code Online (Sandbox Code Playgroud)
但它似乎不起作用。
我更喜欢 javascript/jQuery 解决方案,因为这种模式在网站中很常见
我正在尝试解析逻辑运算符,查询字符串见下文
code!=720 AND first_name=abc OR last_name=def AND status_code=OK
Run Code Online (Sandbox Code Playgroud)
并将解析后的字符串作为二叉树获取。对于上面的表达式,预期的解析表达式应该如下所示
[[['code', '!=', '720'], 'AND', ['first_name', '=', 'abc']], 'OR', [['last_name', '=', 'def'], 'AND', ['status_code', '=', 'OK']]]
Run Code Online (Sandbox Code Playgroud)
我尝试执行此代码,但没有得到所需的输出
operator = pp.Regex(">=|<=|!=|>|<|=").setName("operator")
number = pp.Regex(r'[+-]?\w+(:?\.\w*)?(:?[eE][+-]?\w+)?')
word = pp.Word(pp.alphas, pp.alphanums + "_-*(1234567890 ,)")
term = word | number
condition = pp.Group(term + operator + term)
expr = pp.operatorPrecedence(condition,
[('NOT', 1, pp.opAssoc.RIGHT,),
('AND', 2, pp.opAssoc.LEFT,),
('OR', 2, pp.opAssoc.LEFT,)])
Run Code Online (Sandbox Code Playgroud)
例子
query_string = 'code!=720 AND first_name=abc OR last_name=def AND status_code=OK'
print(expr.parseString(query_string)[0])
Run Code Online (Sandbox Code Playgroud)
并且输出是错误的
[['code', '!=', '720'], 'AND', ['first_name', '=', …Run Code Online (Sandbox Code Playgroud) .NET Core 中无键查询字符串参数的替换是什么?
在 asp.net 中,语法为Request.QueryString[ null ],但是 .NET Core 会为此抛出 null 异常,不允许您传入null键名称。
例如,我需要支持这种格式的url:
http://localhost:54301/RBLeCORS.ashx?{Command:CalcEngineStatus}
然而,除此之外,我需要能够处理通过$.ajax()javascript 调用发布的命令,其中数据被发布而不是放在查询字符串上。
其中 keyless(我看到评论想将其称为 valueless,我猜这适合 .NET Core,但我看到它们被称为 keyless,用于您使用密钥访问的 asp.net b/c null)值是一个 json 对象,可以具有不仅仅是我给出的这个简单的例子。
更新:这是我作为解决方法所做的当前代码。
string queryData = null;
if (context.Request.Query.Count == 1 )
{
var firstKey = context.Request.Query.Keys.ElementAt(0);
var firstValue = context.Request.Query[firstKey];
if ( string.IsNullOrEmpty( firstValue ) )
{
queryData = firstKey;
}
}
Run Code Online (Sandbox Code Playgroud) 我正在寻找构建 URI,例如https://example.com/data/customers?$top=100.
是否有UriBuilder用于创建 OData URI(即可以$适当处理诸如此类的字符)?
我有这样的代码(简化示例):
public Uri CreateMyApiUri(string rootUri, string apiPath, string entity, int pageSize)
{
var builder = new UriBuilder(rootUri);
builder.Path = ConcatPathParts(builder.Path, apiPath, entity); //basically string.Join("/", args), plus code to remove superfluous slashes
var parameters = HttpUtility.ParseQueryString(builder.Query);
if (pageSize > 0) parameters["$top"] = pageSize.ToString();
builder.Query = parameters.ToString();
return builder.Uri;
}
//called like this
var uri = CreateMyApiUri("https://example.com", "data", "customers", 100);
Run Code Online (Sandbox Code Playgroud)
但是,OData 特殊字符$会被编码为在 URI 中使用%24。
我在 GitHub …
我使用 @Angular/router 和 Angular 7。
我的目标是在我的页面之一上使用任意数量的(可选)查询参数,特别是在 /pages/components 中
我面临的问题是,每当我在网址栏中输入一些查询参数时,我就会被重定向到一个奇怪的位置。如果存在任何查询参数,此重定向会发生在我的所有页面上。
例子:
我正在努力理解这个重定向。
看起来第一个查询参数的前 3 个字母被截断,查询字符串的其余部分被转义,并且由于某种原因,我总是以 /pages/components/something 结束,即使我输入的 url 完全是一个不同的页面(也许是因为组件页面是我唯一在 RouterModule 上带有参数的页面?)。
这是我的路由模块:
const appRoutes: Routes = [
{path: '', component: LoginPageComponent, runGuardsAndResolvers:'always', pathMatch: 'full'},
{path: 'pages/components', component: ComponentsPageComponent, runGuardsAndResolvers: 'always'},
{path: 'pages/classes', component: ClassesPageComponent, runGuardsAndResolvers: 'always'},
{path: 'pages/components/:id', component: ComponentsPageComponent, runGuardsAndResolvers: 'always'},
{path: 'pages/dashboard', component: DashboardPageComponent, runGuardsAndResolvers: 'always'},
{path: 'pages/users', component: UserAdminisitrationComponent, runGuardsAndResolvers: 'always', canActivate: [UserRoleGuardService]},
{path: 'pages/reports', component: ReportsPageComponent, runGuardsAndResolvers: 'always'},
{path: 'pages/jobs', …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用以下方法获取查询字符串值:
_httpContextAccessor.HttpContext.Request.QueryString["data"]
Run Code Online (Sandbox Code Playgroud)
但它失败并出现错误:
无法将 [] 索引应用于“QueryString”类型的表达式
QueryString 来自Microsoft.AspNetCore.Http命名空间。
query-string ×10
c# ×3
html ×2
http ×2
javascript ×2
.net-core ×1
angular7 ×1
api ×1
arrays ×1
asp.net-core ×1
get ×1
header ×1
jquery ×1
odata ×1
parsing ×1
post ×1
pyparsing ×1
python-3.x ×1
router ×1
search ×1
spring ×1
uribuilder ×1
url-encoding ×1