Parameter ‘id‘ not found. Available parameters are [id , param1]

Parameter 'id' not found. Available parameters are [id , param1]

  • 解决办法:
    • 1.删除Mapper接口中的@Param("param")
    • 2.xml中写成 #{param.xxx}

MyBatis传入参数时,报错Parameter ‘id’ not found. Available parameters are [id , param1]

解决办法:

1.删除Mapper接口中的@Param(“param”)


 public int  add2(@Param("articleInfo") ArticleInfo articleInfo);

 public int  add( ArticleInfo articleInfo);//对象
    
 public int updateTitle(@Param("id") Integer id ,@Param("title") String title);//普通的变量

2.xml中写成 #{param.xxx}

insert into articleinfo(title,content,uid)
        values(#{articleInfo.title},#{articleInfo.content},#{articleInfo.uid})
 insert into articleinfo(title,content,uid)
        values(#{title},#{content},#{uid})
update articleinfo set title=#{title} where id=#{id}

普通的变量不用像类的属性那样访问

你可能感兴趣的:(Spring,mybatis,java)