首页 > 编程语言 > 详细

springboot后端controller参数接收

时间:2019-07-07 10:54:58      阅读:227      评论:0      收藏:0      [点我收藏+]

参考:https://blog.csdn.net/a532672728/article/details/78057218

 

get方法 :

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

方法一:String test String name,string pwd)   名字匹配直接注入

方法二:String  test(User user)  //user对象的属性名匹配上,自动注入

方法三:String test (HttpServletRequest  request)

               {

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

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

    }

 

方法四:RequestParam    其实和方法一一样,自动匹配不上,手动匹配   

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

 

 

 

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

方法1:  PathVariable:  这个和上面都不一样,上面是用查询字符串,这个是用路由。 此方法和上面四种可以混用。

             路由上写好  @RequestMapping={value= /test/sss/{a}/{b}}

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

    {

     

    }

 post方法:  参考这里:https://blog.csdn.net/suki_rong/article/details/80445880

springboot后端controller参数接收

原文:https://www.cnblogs.com/lhuser/p/11145041.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!