我正在使用 PHP.我想从头开始创建 MVC 设置,以了解有关 MVC 工作原理的更多信息.我想使用带有斜杠的干净 url 作为参数的分隔符.当涉及到 GET 方法表单时,人们如何做到这一点?还是人们一起避免使用 GET 方法形式?
I am using PHP. I want to create an MVC setup from scratch to learn more about how MVC works. I want to use clean urls with slashes as delimiters for the arguments. How do people do this when it comes to GET method forms? Or do people avoid GET method forms all together?
目前我能想到的方法是:
As of right now the ways I can imagine are:
欢迎提出任何建议或建议阅读.
Any suggestions or suggested reading welcome.
获取变量和干净的 URL 并不矛盾.你总是可以有像
Get variables and clean URLs don't contradict each other. You can always have URLs like
http://example.com/controller/action?value1=foo&value2=bar
另一种 URL 样式也可能看起来像
An alternative URL style could also look like
http://example.com/controller/action/value1/foo/值2/条或者http://example.com/controller/action/foo/bar
在这两种情况下,如果您想通过表单 GET 提交创建这些 URL,则必须使用 JavaScript 来组合正确的 URL,因此第一个解决方案可能更容易实现.
In these 2 cases if you want to create these URLs via a form GET submit you will have to use JavaScript to assemble the correct URL therefore the very first solution might be easier to implement.
另一个问题是 POST 和 GET 表单提交之间的决定.POST 更安全,但正如您所说,用户无法为其添加书签.
Another question is the decision between POST and GET form submission. POST is more secure but as you said, users can't bookmark it.
这篇关于如何进行MVC表单url格式化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
Zend 中的动作视图助手 - 解决方法?Action View Helper in Zend - Work around?(Zend 中的动作视图助手 - 解决方法?)
这是将 URI 与 PHP 中用于 MVC 的类/方法匹配的好方Is this a good way to match URI to class/method in PHP for MVC(这是将 URI 与 PHP 中用于 MVC 的类/方法匹配的好方法吗)
我在哪里保存 Zend Framework 中的部分(视图),以便Where do I save partial (views) in Zend Framework, to be accessible for all Views in my App?(我在哪里保存 Zend Framework 中的部分(视图),以
有一个网站的单一入口点.坏的?好的?没问题?Having a single entry point to a website. Bad? Good? Non-issue?(有一个网站的单一入口点.坏的?好的?没问题?)
MVC + 服务层在 Zend 或 PHP 中常见吗?Is MVC + Service Layer common in zend or PHP?(MVC + 服务层在 Zend 或 PHP 中常见吗?)
PHP MVC 方法中的 Hello World 示例Hello World example in MVC approach to PHP(PHP MVC 方法中的 Hello World 示例)