9.16 基于form表单的文件上传实现 ContextType

9.16 基于form表单的文件上传实现 ContextType9.16 基于form表单的文件上传实现 ContextType

 9.16 基于form表单的文件上传实现 ContextType

基于form表单传递普通键值对的方式传递数据: enctype="application/x-ww-form-urlencoded"

基于form表单上传文件 传递数据,非键值对: enctype="multipart/form-data"

    enctype="text/plain" 这种方式几乎不用

基于ajax传递普通键值对的方式传递数据到服务器

 9.16 基于form表单的文件上传实现 ContextType

9.16 基于form表单的文件上传实现 ContextType

9.16 基于form表单的文件上传实现 ContextType

只要请求体有数据,request.body都有值 。但request.post 只有当contentType==urlencoded时,才会从request.body中取值。

 

基于ajax传递json数据的方式到服务器:

9.16 基于form表单的文件上传实现 ContextType

9.16 基于form表单的文件上传实现 ContextType

 

不管以哪种方式传递,body都有值,都可以从body里解析出来。