1、对于此类链接[http://localhost:7398/order/userPage?page=1&pageSize=1](http://localhost:7398/order/userPage?page=1&pageSize=1)
链接内直接出现了page=?,pageSize=?(具体的属性),可以直接在Mapping方法下进行封装。通常是Get。例如:
- public R
> getrecord(Integer page,Integer pageSize){}直接作为参数进行传递(需要与url内的链接传过来的参数名称,能实现自动映射) - public R
> getrecord(Page page){}将传的参数封装成类进行传递 - public R
> getrecord(@RequestParam Integer page,@RequestParam Integer pageSize){}
内带三个属性:value:绑定为同参数名
required: 是否必须有此参数,若无,报错
defaultValue: 默认值填充
public R> getrecord(HttpServletRequest httpServletRequest){ String page = httpServletRequest.getParameter("page"); String pageSize = httpServletRequest.getParameter("pageSize"); }
2、另外一类链接[http://localhost:7398/employee/1](http://localhost:7398/employee/1),链接后的1代表参数id
可在Mapper内声明参数后,使用@PathVariable 注解,例如:
@Getmapping("{id}")
public R getrecord(@PathVariable Long id){}
这样也能获取到id值,多用于Get请求
3、第三类链接,在URL中并没有参数传递,通常是put,post方式
对于前端以json方式传递过来的对象,方法参数使用@RequestBody 自动对对象进行封装,获得对象。
对于前端不是json传递过来的参数,可能是单属性,使用Map进行存储(在获取时候一定要注意:map中的类型------->如Map



