GetMapping报错总结

1. controller 的GetMapping 的错误

首先是出现了两个GetMapping("/{id1}"), GetMapping("/id2") 出现amgious 错误

 GetMapping("/info")
  public AjaxResult getInfo(Request request){
    
    
  //请求的参数比较多的时候使用
}
GetMapping("/info")
 5. public AjaxResult getInfo(@RequestParam("name") String name){
    
    
 此种是请求的参数比较少的时候使用
}

下面这种发请求的时候路径通过?拼接
/info?name=’+name;

2. “String not const to Long ”

这种错误出现的很频繁,可能就是以上的两种情况中的哪一个没有使用妥当。

3. Get的两种传值得方法

a. 路径传参 比如 /name/{id}
b. ?拼接, 比如 name?id=12
c. 如果拼接参数过多,需要将参数放在类里面,直接传递一个类

猜你喜欢

转载自blog.csdn.net/wangleisuiqiansuiyue/article/details/109128548