现在URL大多用/xx/xx的形式,相比?xx=xx&xx=xx有什么好处吗?
现在URL大多用/xx/xx的形式,相比?xx=xx&xx=xx有什么好处吗?
比如?pageNum=1&userId=1相比/pageNum/1/userId/1
回复内容:
现在URL大多用/xx/xx的形式,相比?xx=xx&xx=xx有什么好处吗?
比如?pageNum=1&userId=1相比/pageNum/1/userId/1
谁告诉你现在 URL 都用 /XX/XX的形式的,难道以前不是这样?
/ 是路径
?后面的是查询
自己去看看 google 和 baidu 的查询 url 就知道了
不是更语义化了么xx.php/pageNum/1/userId/1
要获取/删除(http方法的不同)第1页的userId为1的用户
RESTful的API接口
地址静态化,方便收录
题主说的是伪静态的固定链接吧。?xx=xx&xx=xx是GET传值,两者不存在比较。
比如 /post/edit/1024
最后还是要重写成 /index.php?c=post&a=edit&id=1024
或者 /post.php?a=edit&id=1024
交给PHP处理, 或者直接把URI交给index.php分析, 只不过前者更 RESTful 罢了.
seo。。。。。。
前一阵子刚好遇到这个问题呢。
是.net mvc的一个项目,项目中是手动配置的路由(路径),领导说让按第一种的写法。
比如我的会议详情页:.../meeting/detail/1
,数字就是会议的Id;
后来会议有分类了,大类小类的乱七八糟的,要改面包屑显示了,再加一个参数去解决吧.../meeting/detail/1/1
,坏了,好多列表页进不去详情页了,以前列表页都是走的这一个detail页:搜索、直播、录播、专家、国际等待。然后改了一大堆文件,逻辑的。沃日,怎么也算是完成了,反正还是不喜欢这种形式的路径,至少第二种不会引发程序错误。
后来项目上线前用专业工具安全检测的时候,提了一个bug:路径.../search/import
无法访问!!
我去你妹的,这个是import是搜索关键字,你给我当路径?
url哪个形式,还是看个人喜好吧,我觉的。
两个都可以,看场景了,并非所有的场景都适合RESTFul,REST站在一切皆资源的角度,对其的创造只能通过http动词。就像是java把一切都看做名词一样。但这样很麻烦,要考虑各种设计。,”?“反而简单粗暴,速度可能更快(虽然对人类无意义的时间)。
第二种是有针对性的直接按路径进行的查询

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

In this chapter, we are going to learn the following topics related to routing ?

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

Validator can be created by adding the following two lines in the controller.
