java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).

java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).

原因如下:
@Select("select count(*) from pro_mac where id like'%#{val}%' or mac like'%#{val}%'")

where id like'%#{val}%' or mac like'%#{val}%'"中#{val}是带‘’的,显示结果可能为where id like'%‘123’%' ​​​​​​​

所以改为${val}就好了

@Select("select count(*) from pro_mac where id like'%${val}%' or mac like'%${val}%'")

 

你可能感兴趣的:(异常问题,sql,mybatis)