query-string

http_build_query function's excessive urlencoding

折月煮酒 提交于 2019-12-12 13:08:53
问题 Why when building a query string with http_build_query function, it urlencodes square brackets [] outside values and how do get rid of it? $query = array("var" => array("foo" => "value", "bar" => "encodedBracket[")); $queryString = http_build_query($query, "", "&"); var_dump($queryString); var_dump("urldecoded: " . urldecode($queryString)); outputs: var%5Bfoo%5D=value&var%5Bbar%5D=encodedBracket%5B urldecoded: var[foo]=value&var[bar]=encodedBracket[ The function correctly urlencoded a [ in

parse_str randomly adding semicolons to keys

放肆的年华 提交于 2019-12-12 12:12:15
问题 I am passing a query string as part of my query string to a PHP script. Kinda like this: $.post('/url', { id: postID filters: $('#form').serialize() }); Then in my PHP, I use parse_str to read filters : <?php $postID = $this->input->post('id'); parse_str($this->input->post('filters'), $filters); The problem is that parse_str is adding ; s randomly to the keys. I'm getting a result like this: array(4) { ["users"]=> string(0) "" ["companies;"]=> string(0) "" ["pref;_123"]=> string(0) "" [

Pass a list of complex object in query string to WEB API

隐身守侯 提交于 2019-12-12 10:10:05
问题 I have an WEB API method that uses [FromUri] to bind complex type object to my view model, and in this view model, I have a list of complex object inside it. How do I populate this list when I do a GET request? This is my method from WEB API : [HttpGet] public HttpResponseMessage ListPaged([FromUri]PaginationReParams parameters) { // DO SOMETHING HERE... } The PaginationReqParams view model public class PaginationReqParams { public PaginationReqParams() { this.Filters = new List<FiltersReq>()

ASP.NET & Ajax: query string parameters using ISO-8859-1 encoding

♀尐吖头ヾ 提交于 2019-12-12 09:27:58
问题 Here's another one for you to help me solve: I have an ASP.NET website that uses AJAX (asynchronous) calls to am .ashx handler, passing a query string parameter to get some information from the database. Here's an example of how it works: Client-side (Javascript) code snippet that makes the asynchronous call to the handler: /* Capture selected value from a DropDownBox */ var dropdown = document.getElementById(DropDownID); var selectedValue = dropdown.options[dropdown.selectedIndex].value; /*

Arabic QueryString problem (???? in the value)

╄→гoц情女王★ 提交于 2019-12-12 08:57:03
问题 I am sending an arabic value in a querystring, when retrieving it on the server, the value is erroneous and is replaced by quotation marks (????). for example: http://server/mypage.aspx?qs=مرحبا the value of Request.QueryString("qs") is ????? Note that Response.Write('مرحبا') executes correctly. Any idea about this querystring problem? Thanks. 回答1: Just URL Encode the arabic string and it should work fine. Edit: You must URL Encode the string before putting it in the querystring. For instance

Set URL parameters without causing page refresh

扶醉桌前 提交于 2019-12-12 08:27:48
问题 How can you set URL parameters using History.pushState() to avoid browser refreshes? If there is a not a simple JS solution, is there already a popular library or built in function for jQuery? Here is a relevant SO question, where the accepted answer does not actually work according to comments & my test (it removes the query string instead of updating a value): history.pushState() change query values Just to be clear, I am referring to the URL parameters in a query string: http://google.com

.htaccess redirect from GET variable to url string

霸气de小男生 提交于 2019-12-12 08:01:23
问题 I need to redirect /search?keywords=somesearchterm to /search/somesearchterm This seems incredibly basic but I've been pounding my head against it for an hour. Thanks for taking the time to look at this. 回答1: You want to implement what is called a "301 Redirect" with mod_rewrite. RewriteEngine ON RewriteRule ^/search\?keywords=somesearchterm$ /search/somesearchterm adding regular expressions: RewriteEngine ON RewriteRule ^/search\?keywords=(.+) /search/$1 [R=301,L] R=301 means provide a 301

Java Web: Detect a URL with a trailing question mark and empty query string

回眸只為那壹抹淺笑 提交于 2019-12-12 05:45:27
问题 Is there any way I can tell if there is a trailing question mark in a URL? This would theoretically be an empty non null query string while no question mark at all would be a null query string. But either way, my web app is getting request.getQueryString() == null . 回答1: String url = request.getRequestURL().toString(); if(url.indexOf("?")== -1){//it doesn't} 回答2: How about something like this:- boolean hasTrailingQuestionMark = "GET".equals(request.getMethod()) && request.getParameterNames()

URL Rewriting - Query String

梦想的初衷 提交于 2019-12-12 05:26:27
问题 I work on an MVC application and I have urls in the following format: http://127.0.0.1/PDO/PARTIE%20III/index.php?rt=index/connexion http://127.0.0.1/PDO/PARTIE%20III/index.php?rt=index/nouveauMsg I am seeking to rewrite the url so that it reads: http://127.0.0.1/PDO/PARTIE%20III/index/connexion http://127.0.0.1/PDO/PARTIE%20III/index/nouveauMsg Does anyone have any suggestions to help me complete this url_rewrite? That's the router Class that parses the URL and loads the correct view and/or

Query string variables still empty in Express 4

烈酒焚心 提交于 2019-12-12 04:53:40
问题 Write simple server as suggested here on stackoverflow: rest_api.js: const express = require('express'); const bodyParser = require('body-parser') // Initialize RESTful server const app = express(); app.set('port', (process.env.PORT || 5000)); app.use(bodyParser.json() ); // to support JSON-encoded bodies app.use(bodyParser.urlencoded({extended: true})); // to support URL-encoded bodies // Spin up the server app.listen(app.get('port'), function() { console.log('running on port', app.get('port