The method attribute of the @RequestMapping annotation (browsers currently only support get/post requests, and other requests default to get)

The method attribute of the @RequestMapping annotation (browsers currently only support get/post requests, and other requests default to get)

  1. When not set, that is, the default is any request (no matter what get/post/...)
  2. Only post can be used when uploading files (because the post request (the amount of data can be large) is in the request body, while the get request (and the amount of data is limited) is spliced ​​after the path)
  3. Among them, RequestMapping means not only to satisfy its value attribute but also to satisfy the method attribute after setting the Method attribute (RequestMethod.GET)

 

code testing

 

2、

 

That is, you don’t need to write the Method anymore, just write the value and it’s ok. GetMapping has been declared before.

 

 

Verify that the form form can make other requests (except get/post)

 

Guess you like

Origin blog.csdn.net/logtcm4/article/details/126590935