<select id="qryUser" resultClass="java.util.HashMap" parameterClass="java.util.HashMap" > SELECT userId FROM sys_user WHERE 1=1 <isNotEmpty property="userId"> AND userId = "#userId#" </isNotEmpty> </select>
以上语句报错了
SqlMapClient operation; SQL []; \n
--- The error occurred while applying a parameter map. \n
--- Check the roleManagerSqlMap.qryUserAuthorityIds-InlineParameterMap. \n
--- Check the parameter mapping for the ‘userId‘ property. \n
--- Cause: java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException: \n
--- The error occurred while applying a parameter map. \n
--- Check the roleManagerSqlMap.qryUserAuthorityIds-InlineParameterMap. \n
--- Check the parameter mapping for the ‘userId‘ property. \n
--- Cause: java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).
查了半天,原来是因为
<isNotEmpty property="userId"> AND userId = "#userId#" </isNotEmpty>
这个#userId# 外面多了 双引号, 把双引号去掉好了