The backend of dva sending post request cannot accept parameters?

1. I am now using the dva framework to send a post request. The background springmvc cannot receive the parameter
send the request

export async function doApprove(params) {
  console.info(params);
  //return request(`/portal/api/process/saveSp.jhtml?${stringify(params)}`);

  return request("/portal/api/process/saveSp.jhtml", {
    headers: {
            "Content-Type": "application/json;charset=utf-8",
           // "Content-Type": "application/x-www-form-urlencoded",
          //  "Content-Type": "text/plain;charset=UTF-8",
    },
    method: "POST",
      // body: {"param":JSON.stringify(params)},
      body: params,
    // body:{
    //   "taskId:{params.taskId},
    // },
  });
}

mock configuration

  // "POST /portal/api/process/saveSp.jhtml": (req, res) => {
  //   res.send( {code:"1",
  //     msg:"",
  //     data:{
  //     }});
  // },

java background code

@ResponseBody
    @RequestMapping("/saveSp")
    public String saveSp(CompleteTaskVo params,String option,String msgType,HttpServletRequest request, HttpServletResponse response) {
        String taskId = request.getParameter("taskId");
        Enumeration em = request.getParameterNames();
        while (em.hasMoreElements()) {
            String name = (String) em.nextElement();
            String value = request.getParameter(name);
            System.out.println(name);
            System.out.println(value);
        }
Mar.28,2021

you can't get it if you write like this. For
request.body to pass parameters, springmvc should add @ RequestBody annotation to the API parameters.

Menu