receiving the rear end of the controller parameter springboot

Reference: https: //blog.csdn.net/a532672728/article/details/78057218

 

get method:

1. http://localhost:8080/0919/test1?name=xxx&pwd=yyy

Method One: String test String name, string pwd) directly injected into the match name

Method two: the String test (User user) // property name matches the user object, the automatic injector

方法三:String test (HttpServletRequest  request)

               {

                  String name=request.getParameter("name");

     String pwd=request.getParameter("pwd");              

    }

 

Method four: RequestParam fact, and as a method, not on the automatic matching, manual matching   

     String test(@RequestParam(“name”) aaa,@RequestParam(“pwd”),bbb)

 

 

 

2.  http://localhost:8080/0919/test/xxx/yyy

Method 1: PathVariable: The above is not the same, is above the query string, this routing is used. This method and the four kinds can be mixed.

             Written @ RequestMapping = {value = / test / sss / {a} / {b}} routing

             String test (@PathVariable a String Name, @ PathVariable b String Pwd)

    {

     

    }

 post method: Reference herein: https://blog.csdn.net/suki_rong/article/details/80445880

Guess you like

Origin www.cnblogs.com/lhuser/p/11145041.html