我在查询字符串中传递带有点的变量.Php正在用低于分数替换点.那么如何保留名称中包含点的变量名称
HTTP://localhost/sample.php此时就把one.txt存盘= ON&two.txt =上
sample.php
$ ret = $ _ REQUEST ['one.txt']; //不工作
我有一个选择下拉列表,其id映射到值.在onChange事件上,我想重定向到同一个url但是在查询字符串后附加了'id = value'.
如何检查此'id'选项是否已存在于查询字符串中(我不想要多个值)并根据需要替换/追加.
我如何检查'?' 已经在查询字符串中并且如果不是则附加到url.
使用jquery有一个简单的方法吗?
它必须在引擎盖下做类似的事情$().ajax(url, {options}) .我希望我能做到$().redirect( url, { id : $(this).val() })或做某事.
提前致谢.
注意:此页面可能有或没有传入一些不同的查询选项(在其他表单选项上设置默认值),因此替换整个查询字符串不是一个选项.
<html>
<head><script type="text/javascript" src="/jquery-1.3.2.min.js"></script></head>
<body>
<script>
$(function(){
$('#selector').change(function(){
// problem if 'id' option already exists
var url = location.href + '?;id=' + $(this).val();
location.assign( url );
});
});
</script>
<a href="#" onclick="location.assign( location.pathname )">reset</a>
<form>
<select id='selector' name='id'>
<option value='1'>one</option>
<option value='2'>two</option>
<option value='3'>three</option>
</select>
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 我一直在使用哈希在页面之间传递数据(比如设置scrollTop()等),并且还使用hashChange事件来触发给定页面上的更改.
但是,哈希具有我不一定感兴趣的默认行为,例如使页面跳转到给定(有时无关紧要)的位置.
我觉得获取/设置查询字符串会更合乎逻辑,但是:
是吗?
设置查询字符串时是否有可以监听的事件?
我应该知道与查询字符串相关的行为吗?
在ASP.NET中使用QueryString时,我一直在寻找一些最佳实践指南,但实际上并没有找到.
我找到了一篇有用的优化文章:http://dotnetperls.com/querystring
但我更感兴趣的是回答以下问题:
等等...
任何更多的指南将不胜感激!
我试图从asp.net应用程序发送请求到这样的"http://mysite.dk/tværs?test=æ"的URL,并且我无法正确编码查询字符串.或者可能正确编码了查询字符串,我连接的服务只是无法正确理解.
我试图用不同的浏览器发送请求并记录他们如何使用Wireshark对请求进行编码,我得到了以下结果:
Firefox: http://mysite.dk/tv%C3%A6rs?test=%E6 Ie8: http://mysite.dk/tv%C3%A6rs?test=\xe6 Curl: http://mysite.dk/tv\xe6rs?test=\xe6
Firefox,IE和Curl都会从服务中获得正确的结果.请注意,它们在查询字符串中以不同方式编码丹麦特殊字符'æ'.
当我使用HttpWebRequest从我的asp.net应用程序发送请求时,URL以这种方式编码:
http://mysite.dk/tv%C3%A6rs?test=%C3%A6
它以与url的路径部分相同的方式对查询字符串进行编码.远程服务不理解这种编码,所以我得不到正确的答案.
记录中,'æ'(U + 00E6)是ISO-LATIN-1中的%E6,以及UTF-8中的%C3%A6.
我可以更改远程服务以接受UTF-8编码的查询字符串,但随后该服务将停止在浏览器中工作,我对此并不感兴趣.有没有办法指定.NET不应该使用UTF-8编码查询字符串?
我正在创建这样的webrequest:
var req = WebRequest.Create("http://mysite.dk/tværs?test=æ") as HttpWebRequest;
Run Code Online (Sandbox Code Playgroud)
但问题似乎来自System.Uri,它显然是在WebRequest.Create中使用的:
var uri = new Uri("http://mysite.dk/tværs?test=æ");
// now uri.AbsolutePath == "http://mysite.dk/tv%C3%A6rs?test=%C3%A6"
Run Code Online (Sandbox Code Playgroud) 我有一个标准对象,它的某些属性可以为空,如果我不做任何事情,查询字符串包括那些&p=undefined不受欢迎的,因为在 WebApi 中,这些来自"null"而不是null
因此在 Angular 客户端中给出
return this._http
.get<ExposureDifference[]>(AppSettings.ExposureRunDataQueryString, {params : <any>criteria, withCredentials: true})
.catch<any, ExposureDifference[]>(this._trace.handleError("GET " + AppSettings.ExposureRunDataQueryString + criteria, []))
.finally(() => this.isLoading = false);
Run Code Online (Sandbox Code Playgroud)
我可以得到查询字符串
http://localhost:63037/api/exposureRuns/data/?id=3&secsymb=undefined&fund=EL&esectype=SWAP_CDS
Run Code Online (Sandbox Code Playgroud)
有没有办法从查询字符串中排除未定义的参数?
query-string querystringparameter asp.net-core-webapi asp.net-core-2.0 angular
我想为我的高级过滤器生成一个查询字符串。我的对象如下所示:
{
searchValue: {
firstName: "John",
lastName: "Doe",
postalCode: "3130",
city: "New York"
},
page: 1
}
Run Code Online (Sandbox Code Playgroud)
我正在使用查询字符串库来尝试格式化我想要的字符串。
export function updateAdvancedSearchQueryString<T>(props: RouteComponentProps, newValues: T) {
props.history.push({
pathname: props.location.pathname,
search: queryString.stringify(newValues)
});
}
Run Code Online (Sandbox Code Playgroud)
我想要实现的输出:
/trainers?page=1&searchValue=firstName=John&lastName=Doe&postalCode=3130&city=New_York
我目前得到的输出:
/trainers?page=1&searchValue=%5Bobject%20Object%5D
Run Code Online (Sandbox Code Playgroud)
如何从嵌套对象生成所需的查询字符串?
我正在使用 Node + TypeScript 和集成的 swagger 进行 API 调用。我有一个大摇大摆的请求
这里我想找到 username = test 的记录。
因此,我使用 URL 模块解析查询字符串,如下所示,并在控制台中获取用户名。
var params = URL.parse(req.url, true).query;
console.log(params); //gives me [Object: null prototype] { username: 'test' } in my console
Run Code Online (Sandbox Code Playgroud)
但是每当我尝试将 params.username 分配给如下所示的常量时
const username:string =params.username;
Run Code Online (Sandbox Code Playgroud)
它给了我以下错误
输入“字符串|” string[]' 不可分配给类型“string”。类型“string[]”不可分配给类型“string”。
我的完整代码如下
import * as URL from 'url';
public getUserByName = async (req: Request, res: Response, next: NextFunction) => {
var params = URL.parse(req.url, true).query;
const username:string =params.username;
try {
const findOneUserData: Employee = await …Run Code Online (Sandbox Code Playgroud) POST当使用正文中的 和其他参数发出请求时,许多服务可以接受 URL 中的查询字符串参数Content-Type: application/x-www-form-urlencoded,但 AWS API Gateway 似乎不能同时接受查询字符串参数。
POST当我使用映射模板和查询字符串 URL 参数(使用 Lambda 函数)调用 AWS API Gateway 时application/x-www-form-urlencoded,出现以下错误:
{
"message":"When Content-Type:application/x-www-form-urlencoded,
URL cannot include query-string parameters (after '?'):
'/prod/webhook?inputType=wootric&outputType=glip&url=...'"
}
Run Code Online (Sandbox Code Playgroud)
下面是一个 cURL 示例:
curl -XPOST 'https://{myid}.execute-api.{myregion}.amazonaws.com/prod/webhook? \
inputType=wootric&outputType=glip&url=https://hooks.glip.com/webhook/ \
11112222-3333-4444-5555-666677778888' \
-d "@docs/handlers/wootric/event-example_response-created.txt" \
-H 'Content-Type: application/x-www-form-urlencoded' -v
Run Code Online (Sandbox Code Playgroud)
具体目标是使用带有查询字符串参数的 URL 将 Wootric Webhook 事件发布到 Lambda 函数。
您可以在这里获取代码:
https://github.com/grokify/chathooks
Woodric 事件正文文件位于此处:
GitHub问题在这里:
https://github.com/grokify/chathooks/issues/15
错误消息似乎很明确,但我想问:
如果没有解决方案,除了部署像 Heroku 这样的托管服务器解决方案之外,是否还有一个好的轻量级解决方案。另外,其他云服务是否通过 API 网关 …
amazon-web-services query-string aws-api-gateway x-www-form-urlencoded
每个月我们都会向提出请求的客户和网站用户发送一封合法电子邮件。例如,上个月,我们发出了 10,163 封电子邮件,其中 887 封(即约 9%)表现出以下行为(每个月的比例似乎相当一致 - 我的一个理论是,它仅适用于查询字符串中的长数字其价值约为 3600000!)。
该电子邮件包含一个名为 p 的查询字符串参数,它始终为 6 或 7 位数字,另一个名为 nl 的查询字符串参数为 4 位数字。nl 的值保持不变(无论使用的查询字符串参数的顺序如何),但 p 的值通过向每个数字随机添加 2 或 3 来更改(似乎稍微偏爱 3)。然后,电子邮件客户端(或垃圾邮件过滤器?)单击电子邮件中进行此调整的每个链接。
我不介意机器产生额外的流量,尽管我花了一段时间才意识到发生了什么,但有人能对这个问题有更多的了解吗?如果我没有花了很长时间做侦探工作,我不会相信上面的解释是现实合理的!
query-string ×10
asp.net ×2
javascript ×2
url ×2
angular ×1
c# ×1
email-client ×1
encoding ×1
http ×1
jquery ×1
node.js ×1
parameters ×1
php ×1
reactjs ×1
swagger ×1
typescript ×1