比如后端用的是x-www-form-urlencoded
格式的.
js对象是:
{
"id":1,
"user":{"id":1}
}
后端正确的接收格式 id=1&user.id=1这的. 而query-string 生成的是id=1&user[id]=1
这样的
这样直接用jq的ajax 设置为x-www-form-urlencoded 提交对象生成的是id=1&user[id]=1
所以后端就接收不到了.
所以提交起来挺麻烦的.
x-www-form-urlencoded
和 query-string
的关系是怎么样的?
If the format required by the backend must be
id=1&user.id=1
, then the JSON provided by the frontend should be:If the front end cannot be changed and must be passed
id=1&user[id]=1
, then the back end can only adapt to it. I don’t know if Spring MVC supports parameters with square brackets. If it is a Servlet, it is very simple: