In SpringMVC, why does the foreground pass in one parameter and controller accepts two parameters?

topic description

Why does the foreground pass in one parameter in SpringMVC, but controller accepts two parameters?
doesn"t understand this all the time. I hope you can help me.

background:

@PostMapping("/uploadFace")
    public JSONResult uploadFace(String userId, @RequestParam("file") MultipartFile[] files) throws IOException {

Front desk:

 wx.uploadFile({
          url: serverUrl + "/user/uploadFace?userId=" + app.userInfo.id,
          filePath: tempFilePaths[0],
          name: "file",
          header: {
            "content-type": "application/json"
          }
Jun.08,2022
The

parameter is not necessarily on the url, you can also use the post form to submit you to see if there is a file < input > tag


after you encounter this problem, you can directly click in to see the source code of Spring.
you will see that he parses not only the content of queryString, but also the content of body.
in other words, the result depends on the Spring framework, which may not be the case if you change the framework, so look at the source code analysis for yourself.

Menu