POST Required String parameter ‘****‘ is not present

Scenes:

code show as below:

    @RequestMapping(value = "/javaserial.do",method = RequestMethod.POST)
    @ResponseBody
    public ModelAndView JavaSerial(@RequestParam("serial") String serial) throws Exception {
        String string =  javaserial(serial);
        ModelAndView mv = new ModelAndView();
        mv.addObject("output", string);
        mv.setViewName("serial");
        return mv;
    }

Here I set RequestMethod.POST, but when I send the post request, I can see the error:

solve:

There are many solutions on the Internet, but they are not reliable. Here we explain that the main causes of this problem are the following problems:

Situation one:

Are you sure you added RequestMethod.POST?

@RequestMapping(value = "/javaserial.do",method = RequestMethod.POST)

Situation two:

The submitted data package must contain Content-Type: application/x-www-form-urlencoded

Situation three:

When jquery submits delete, it does not support @RequestParam and only supports the @PathVariable form.

There are almost these three categories. If you find that you cannot receive post data, you must remember to capture the packet to see if the content contains Content-Type: application/x-www-form-urlencoded

Guess you like

Origin blog.csdn.net/GalaxySpaceX/article/details/132837939