是否存在要遵循的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参数命名约定或标准是什么
发布评论