param就是得到方法中参数的名字,MyBatis通过参数名字得到参数的值例如:

MyBatis中param的作用

 

在写代码时,尽量保持Param中的名字与所传参数名一致,这样比较好区分。

MyBatis中param的作用

多个参数时,参数必须要用Param注解,单个参数可以不用,但还是建议使用。

多个参数不使用注解时会报2019-02-18 15:14:00.489 |DESKTOP-25P9U7B| [http-nio-8101-exec-14] ERROR o.a.c.core.ContainerBase.[Tomcat].[localhost].[/].[dispatcherServlet]:182 - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'status' not found. Available parameters are [arg1, id, param1, param2]] with root cause
org.apache.ibatis.binding.BindingException: Parameter 'status' not found. Available parameters are [arg1, id, param1, param2]

第一次写博客,大佬们轻点喷。

相关文章:

  • 2022-12-23
  • 2021-07-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-28
  • 2022-12-23
  • 2021-11-01
  • 2021-09-09
  • 2021-08-28
相关资源
相似解决方案