我有一个用javascript编写的大部分代码的应用程序。 我遇到一个奇怪的问题。 我有一个查询字符串,我的应用程序读取它执行各种操作。 昨天我改变了查询字符串参数的排序并且应用程序停止工作。 如果我把原来的订单放回去,那么它开始工作。 可能是什么原因? 我认为参数排序的效果应该不重要。 但是,显然它出于某种原因很重要。 我仍然试图找出可能存在的问题,但想知道这里是否有人遇到过类似的问题?
谢谢。
I have an application with most of the code written in javascript. I am encountering a strange problem. I have a query string and my app reads it to perform various actions. Yesterday I changed the ordering of the query string parameters and the application stopped working. If I put the original order back then it starts working. What could be the reason? I thought that the effect of ordering of parameters should not matter. But, apparently it does matter for some reason. I am still trying to dig out what can be the issue but wanted to know if any one here has encountered a similar problem?
Thanks.
最满意答案
正确编写的应用程序将以任何顺序查找给定的查询参数,并且不会对顺序敏感。 虽然编写得很差的解析代码是可能的,但只能在开始,结束时或仅在其他参数后面找到给定参数。 在没有看到解析查询参数的代码的情况下,我们不能真正说出它有什么问题,但是可能会写入对位置不敏感的代码。
如果您发布解析查询参数的代码以及可以工作的查询字符串,而不是那种查询字符串,我们可以更具体地提出建议。 您还应该检查以确保您的查询参数没有任何应该被编码的字符,这些字符可能会丢掉任何东西。
A properly written application will find a given query parameter in any order and will not be order sensitive. It is possible though to have poorly written parsing code that would only find a given parameter at the beginning, at the end, or only if after some other parameter. Without seeing the code that parses the query parameters, we can't really say what problem it has, but it is possible to have poorly written code that is position-sensitive.
If you post the code that parses the query parameters and the query string that works and the one that doesn't, we could advise more specifically. You should also check to make sure that your query parameters don't have any characters in them that are supposed to be encoded that could be throwing things off.
更多推荐
发布评论