POST与CMS中的搜索表单的GET方法 [英] POST vs GET method for a search form in CMS

查看:153
本文介绍了POST与CMS中的搜索表单的GET方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有点被卡住了一件事。只是不能决定是否在我的搜索表单中使用POST或GET方法。



通常情况下,我会对这种表单使用GET方法,因此用户可以为他们的结果添加书签。但是这一次,搜索表单出现在管理区域,所以结果很快就会相关,并且不需要将结果添加书签,当然,它们不是每个人都公开的。



更具体地说,搜索功能是与用户列表一起使用的,所以可能会有一些特定的用户被搜索。我的想法是使用POST方法,其中表单将被重定向到相同的页面,所以我会得到由搜索字符串过滤的用户列表。还有分页,所以我会在每个分页链接和每个分页链接上添加搜索字符串(下一页,上一页,第一页和最后一页链接),以便稍后不会丢失搜索字符串(在任何会话之后像搜索结果分页等搜索)。



没有明显的理由可以使用一个在另一个之前。 POST方法会稍微麻烦一点,但另一方面,搜索表单中有高级选项(大约5个复选框),我不喜欢用URL方式填充太多值的想法(我希望用户不要经常在搜索会话后使用分页,所以如果经常使用POST方法,这些值不会经常到达地址栏。)



哪一个你喜欢在CMS和类似系统中搜索吗?



谢谢大家!

解决方案

您正在获取数据,因此请使用GET。 POST会在刷新和返回时产生问题。



不要迷恋URI的美丽,它们不是一件艺术品。


I'm a bit stuck with one thing. Just can't make up my mind on whether to use POST or GET method at my search form.

Normally I would use GET method for such a form, so users could bookmark their results they got. But this time, the search form is present in administration area, so results are relevant shortly and there is no need to bookmark results and of course, they aren't public for everyone.

To be more specific, the search feature is meant to be used along with a list of users, so there could be some specific user to be searched. My idea was to use POST method, where the form would be redirected to the same page so I would get a list of users filtered by search string. There was also pagination, so I would add the search string at the and of each pagination link (next page, previous page, first page and last page link) so the search string wouldn't be lost later on (within any session coming after the search like paginating of searched results etc.).

There is no obvious reason to prefer one before another, both can be used. The POST method would be a little bit more hassle, but on the other hand, there are advanced options within the search form (about 5 checkboxes) and I don't like the idea of having meesed up URL bar with way too many values (and I expect users not to use pagination after search session so often, so the values wouldn't get to the address bar so often) if POST method used.

Which one would you prefer for searching in CMS and alike systems?

Thanks everyone!

解决方案

You are getting data, so use GET. POST will create issues with refreshing and going back.

Don't obsess over the beauty of your URIs, they are a tool not a piece of art.

这篇关于POST与CMS中的搜索表单的GET方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆