1.判斷參數使用:_parameter
<select id="findCount" parameterType="int" resultType="int"> SELECT COUNT(id) FROM vote <where> <if test="_parameter != null">isuse=#{isuse}</if> </where> </select>
2.或者修改接口:
int findCount(int isuse);
改為:
int findCount(@Param(value="cmpid") int isuse);
3.一般出錯原因:Mybatis默認采用ONGL解析參數,所以會自動采用對象樹的形式取Integer.cmpid。Integer對象沒有cmpid屬性。如果不解析參數,mybatis自動識別傳入的參數,不會報錯。