Mybatis报无效的关系运算符异常

ORA-00920:无效的关系运算符
工作需要将where条件封装到map中,where=name=ls,通过调试能获取name=ls,但查询时出现异常
where 1=1

and #{where}

把#{where}换成1=1可以查询 map封装的where参数就是不行,哪位高手帮忙解决问题啊。

String sl=sl; sl 是你sl 的变量名
String where ="name='sl'";
应该是 testMap.put("where",where),
and ${where}

你把where封装到了map对象中,那就得从这个map中获取这个where参数,
例如你的map对象是Map testMap,你的where对象存放到这个testMap中,testMap.put("where",where),
然后在mybatis里用#{testMap.where}获取

那就是map封装出问题了?
你的map 中key是where value是name=ls?
ls是啥?变量还是字符串 name=“ls”?

解析成sql应该变成了and name = ls 吧,表达式肯定是报错了的

将where 改为 String where ="name='"+sl+"'";

把#{where} 换成${where} 试一下

写动态SQL拼接where语句吧