一、问题:
前台vue使用fetch.js发送post请求后,后台 request.getParameter()无法获取到参数值
二、思路:
- Status Code: 200 OK请求发送成功
- 查看浏览器request请求中有参数查看浏览器request请求中有参数
- 后台controller中使用 request.getParameter(“account”),参数名称一致
- 仔细对比以前发送的post请求发现request参数传递格式不一样
- 查阅相关资料,原因为fetch.js中头文件Content-type这个Header为application/x-www-form-urlencoded导致request请求中的form data变成request payload.
三、处理办法:
后台controller中使用流接受数据后,再进行查询操作既可。
-
vue代码
/** * 获取行业大类 */ export const hangyebrief = industryId => fetch('/console/good/industry/findIndustry', { industryId: 2 }, 'POST');
-
controller代码