2 回答
TA贡献1829条经验 获得超4个赞
顺便提一下,即使是用springmvc的注解 : RequestParam ,也是取不到的,整个表单数据都是空的
我是用工具自己一个一个字符写的报文,也用jsp试过,同样拿到400
<form action="${pageContext.request.contextPath }/demo.ember" method="post">
<input type="text" name="username"/>
<input type="text" name="password"/>
<input type="submit" value="提交"/>
</form>
错误返回:
HTTP Status 400 - Required String parameter 'username' is not present
浏览器调试,发送的报文:
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip, deflate
Accept-Language:en-US,en;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Content-Length:26
Content-Type:application/x-www-form-urlencoded
Cookie:JSESSIONID=7872810B7BE203B784A906C3D49418D1
Host:localhost:8080
Origin:http://localhost:8080
Referer:http://localhost:8080/BugTest/demo.jsp
Upgrade-Insecure-Requests:1
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.97 Safari/537.36
username=wsa&password=esdx
在后台,用HttpServelet获取ContentType,的确为application/x-www-form-urlencoded,但是获取整个ParameterMap或者单个Parameter,都是空,获取body,也是空,但是换成GET,参数放在url中,完全没有问题
今天到了公司,将代码重新敲了一遍,一模一样的代码,公司是可以取到的,各种测试都是通的,不知道为什么在家里取不到,分析下原因:
初步估计为tomcat版本引发的bug,公司中用的tomcat版本为8.0.29 ,家里的不知道,今晚回去查下tomcat版本,顺便查下该版本的bug list
持续更新。。。
fix了,是tomcat8.0.29的一个bug,大家用表单数据的时候注意了,当然,写rest的不用管
添加回答
举报
