遵循的url参数命名约定或标准是什么

编程入门 行业动态 更新时间:2024-10-21 03:58:01
本文介绍了遵循的url参数命名约定或标准是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

是否存在要遵循的Url参数的命名约定或标准。我通常使用骆驼套,例如 userId 或 itemNumber 。当我要开始一个新项目时,我正在搜索是否有与此相关的任何东西,但找不到任何东西。我不是从语言或框架的角度看待这个问题,而是将其作为一般的Web标准。

Are there any naming conventions or standards for Url parameters to be followed. I generally use camel casing like userId or itemNumber. As I am about to start off a new project, I was searching whether there is anything for this, and could not find anything. I am not looking at this from a perspective of language or framework but more as a general web standard.

推荐答案

我建议阅读酷URI的不变 ,以深入了解此问题。如果您在URI中使用参数,则最好重写它们以反映数据的实际含义。

I recommend reading Cool URI's Don't Change by Tim Berners-Lee for an insight into this question. If you're using parameters in your URI, it might be better to rewrite them to reflect what the data actually means.

因此,不要使用以下内容:

So instead of having the following:

/index.jsp?isbn=1234567890 /author-details.jsp?isbn=1234567890 /related.jsp?isbn=1234567890

您将拥有

/isbn/1234567890/index /isbn/1234567890/author-details /isbn/1234567890/related

它创建了一个更明显的数据结构,这意味着如果您更改平台体系结构,则URI不会更改。没有上述结构,

It creates a more obvious data structure, and means that if you change the platform architecture, your URI's don't change. Without the above structure,

/index.jsp?isbn=1234567890

成为

/index.aspx?isbn=1234567890

这意味着您网站上的所有链接现在都已断开。

which means all the links on your site are now broken.

通常,仅当用户可以合理地期望生成要检索的数据时,才应使用查询字符串。搜索。如果您使用查询字符串从数据库中检索不变的资源,请使用URL重写。

In general, you should only use query strings when the user could reasonably expect the data they're retrieving to be generated, e.g. with a search. If you're using a query string to retrieve an unchanging resource from a database, then use URL-rewriting.

更多推荐

遵循的url参数命名约定或标准是什么

本文发布于:2023-10-09 06:08:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1474911.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:参数   标准   url

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!