10

RESTer发送post请求与表单post请求的区别

测试时发现一个很蛋疼的问题, 使用form表单提交时servlet可以正常获取参数, 但是使用Rester测试则获取参数失败, 直接为null;

有没有前辈遇到过这种问题;

参数获取方法均采用最基础的req.getParameter();

两组请求只有请求头不同;

失败的请求头

Host: 127.0.0.1:9090
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:58.0) Gecko/20100101 Firefox/58.0
Accept: */*
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
content-type: text/plain;charset=UTF-8
origin: moz-extension://f6c667d7-d221-4f5e-aa91-67e75dfe5914
Content-Length: 44
Cookie: JSESSIONID=1833498450D841AEFAFBEA47328A6E4B
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache

成功的请求头

Host: 127.0.0.1:9090
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:58.0) Gecko/20100101 Firefox/58.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
Referer: http://127.0.0.1:9090/RequestResponseServlet/test.jsp
Content-Type: application/x-www-form-urlencoded
Content-Length: 44
Cookie: JSESSIONID=1833498450D841AEFAFBEA47328A6E4B
Connection: keep-alive
Upgrade-Insecure-Requests: 1
查看全部
qq_35866377
null丨QAQ
2019/08/15 16:43
  • java
  • tomcat
  • java-ee
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

2个回复