參考: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