Spring Boot 如何获取请求参数 formData - 使用 request.getParameter() 方法
青黛: \nlet formData = {\n yfStocks : JSON.stringify(this.table1.dataSource)\n};\ndefHttp\n .post({\n url: this.url.yfYpLrInfo,\n params: formData,\n })\n .then((result) => {\n this.table1.selectedRows = [];\n })\n .finally(() => {\n this.table1.loading = false;\n });\n\n青黛: \n@RequestMapping(value = "/yfYpLrInfo", method = RequestMethod.POST)\n@ResponseBody\npublic Result> yfYpLrInfo(HttpServletRequest request) {\n String ste = request.getParameter("0");\n}\n如何获取request里的formData数据内容:要获取request里的formData数据,可以使用request.getParameter()方法。根据代码中的例子,formData数据是通过params参数传递的,所以可以使用request.getParameter("yfStocks")来获取formData数据。修改代码如下:\n\n```java\n@RequestMapping(value = "/yfYpLrInfo", method = RequestMethod.POST)\n@ResponseBody\npublic Result> yfYpLrInfo(HttpServletRequest request) {\n String yfStocks = request.getParameter("yfStocks");\n // 处理formData数据\n}\n```\n\n在上述代码中,通过request.getParameter("yfStocks")获取到了formData数据的值,并将其赋值给了yfStocks变量。然后可以根据需要对这个formData数据进行处理。
原文地址: https://www.cveoy.top/t/topic/qk1h 著作权归作者所有。请勿转载和采集!