There is no getter for property named 'deptIds' in 'class java.lang.String'

报这种错误头疼,什么传字符串参数默认用_parameter,

在参数前面加@Param(value="XXX")通通没有用。

Java:

        @Override
	public int getPersonCountByDeptIds(String deptIds) throws Exception {
		return this.selectOne("DepartmentExtXML.getPersonCountByDeptIds", deptIds);
	}

 XML:

        <!--根据部门子ids字符串获取下属人数 Y -->
	<select id="getPersonCountByDeptIds" resultType="java.lang.Integer" >
		SELECT count(*)
		FROM tbl_personnel_emp_details
		WHERE del_flag = 1
		AND department_id IN (${deptIds})
	</select>

我认为xml没有问题,觉得是传参让Mybatis的xml不识别的问题。Java代码改成如下就好了

        @Override
	public int getPersonCountByDeptIds(String deptIds) throws Exception {
		HashMap<String, Object> values = new HashMap<String,Object>();
		values.put("deptIds", deptIds);
		return this.selectOne("DepartmentExtXML.getPersonCountByDeptIds", values);
	}

希望对你有帮助!

猜你喜欢

转载自blog.csdn.net/hqbootstrap1/article/details/81540324