enctype=application/x-www-form-urlencoded get方式php
内容部分:title=test&content=%B3%AC%BC%B6%C5%AE%C9%FA&submit=post+articlespring
读取数据: request.getParameter() 由于按流读取后数据后,其余方法读不到数据。mvc
enctype=multipart/form-data post方式app
内容部分:post
POST /post_test.php?t=1 HTTP/1.1 Accept-Language: zh-CN User-Agent: Mozilla/4.0 Content-Type: multipart/form-data; boundary=---------------------------7dbf514701e8 Accept-Encoding: gzip, deflate Host: 192.168.12.102 Content-Length: 345 Connection: Keep-Alive Cache-Control: no-cache -----------------------------7dbf514701e8 Content-Disposition: form-data; name="title" test -----------------------------7dbf514701e8 Content-Disposition: form-data; name="content" .... -----------------------------7dbf514701e8 Content-Disposition: form-data; name="submit" post article -----------------------------7dbf514701e8--
Content-Type中定义boundary在内容中用到。url
读取数据:request.getParameter() 读不到数据,request.getInputStream()和request.getReader() 在同一个request中混合使用会抛出异常。code
springmvc 中 CommonsMultipartResolver.resolveMultipart(HttpServletRequest request) 完成了对两种状况的递交数据的解析,使咱们方便的获取参数而不用有太多顾及。orm