【发布时间】:2014-07-25 13:05:13
【问题描述】:
我想知道一些关于如何为 URL 实现错误检测算法的可能想法。我的网址可以按如下方式工作:
http://changes.html?Type=Production&Item=Tires&Type=Winter
My Url can have the following forms:
http://changes.html?Type=Production //which gets you to the base page
http://changes.html?Type=Production&Item=Tires //which gives you all the tire options
http://changes.html?Type=Production&Item=Tires&Type=Winter //which gives you a specific tire
我的问题是,如果我拼写 Type=Production 错误,以至于我拼写为Tzxpe=Poductaion,那么我可能会考虑使用默认页面。此外,如果说一切都是正确的,直到键入这样你有以下 URL:
http://changes.html?Type=Production&Item=Tires&TZAe=Wter 然后我想在轮胎处切断绳子,直到它正确并编程一个页面重定向到该工作部分。我的解决方案似乎有点奇怪和低效。有没有更好的方法来修复 URL,或者更好地实现我的想法,或者只是一种完全不同的方法来解决这个问题?错误检查对于这个项目来说是必须的,所以仅仅收到一个错误的 url 消息并不能解决它!
【问题讨论】:
-
为什么错误检查如此重要?通常这些 URL 不会直接输入到栏上,确定吗?
-
你能用正则表达式吗?
标签: javascript html algorithm web error-handling