在node.js中使用request.body或request.params有什么区别吗? [英] Is there any difference between using request.body or request.params in node.js?

查看:346
本文介绍了在node.js中使用request.body或request.params有什么区别吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道在从客户端向服务器发送数据时是否有任何偏好在node.js中使用request.body或request.params?

I am wondering if there is any preference in using request.body or request.params in node.js when sending data from client to server?

推荐答案

您可以在正文中容纳比在网址中更多(不同)的数据。您可以在正文中传递任何字符串(特殊字符),而在URL中对它们进行编码会使您容易受到状态414(Request-URI Too Long)的攻击。在传递数组和复杂对象时使用正文要容易得多:)

You can fit more (diverse) data in the body than in the url. You can pass any string (special characters) in the body, while encoding them in the url would get you vulnerable to status 414 (Request-URI Too Long). And it's a lot easier to use the body when passing arrays and complex objects :)

这篇关于在node.js中使用request.body或request.params有什么区别吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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